01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02 *
03 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
04 *
05 * "Hilbert II" is free software; you can redistribute
06 * it and/or modify it under the terms of the GNU General Public
07 * License as published by the Free Software Foundation; either
08 * version 2 of the License, or (at your option) any later version.
09 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16 package org.qedeq.kernel.bo.module;
17
18 import org.qedeq.kernel.se.common.State;
19
20 /**
21 * Represents a module state. Every instance of this class should be unique.
22 *
23 * @author Michael Meyling
24 */
25 public class PluginState implements State {
26
27 /** meaning of this state. */
28 private final String text;
29
30 /** is this state a failure? */
31 private final boolean failure;
32
33 /** Code for state. */
34 private final int code;
35
36 /**
37 * Creates new module state.
38 *
39 * @param text meaning of this state, <code>null</code> is not permitted.
40 * @param failure is this a failure state?
41 * @param code code of this state.
42 * @throws IllegalArgumentException text == <code>null</code>
43 */
44 public PluginState(final String text, final boolean failure, final int code) {
45 this.text = text;
46 if (this.text == null) {
47 throw new IllegalArgumentException("text==null");
48 }
49 this.failure = failure;
50 this.code = code;
51 }
52
53 public String getText() {
54 return this.text;
55 }
56
57 public boolean isFailure() {
58 return this.failure;
59 }
60
61 public int getCode() {
62 return this.code;
63 }
64
65 public String toString() {
66 return this.text;
67 }
68
69 public int hashCode() {
70 return this.text.hashCode();
71 }
72
73 public boolean equals(final Object obj) {
74 // every instance is unique
75 return (this == obj);
76 }
77
78 }
|