001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002 *
003 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
004 *
005 * "Hilbert II" is free software; you can redistribute
006 * it and/or modify it under the terms of the GNU General Public
007 * License as published by the Free Software Foundation; either
008 * version 2 of the License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU General Public License for more details.
014 */
015
016 package org.qedeq.kernel.se.common;
017
018 /**
019 * Represents a mathematical module state. Every instance of this class is unique.
020 *
021 * @author Michael Meyling
022 */
023 public final class LogicalModuleState implements State {
024
025 /** Unchecked. */
026 public static final LogicalModuleState STATE_UNCHECKED
027 = new LogicalModuleState(LogicalModuleStateDescriptions.STATE_STRING_UNCHECKED,
028 false, LogicalModuleStateDescriptions.STATE_CODE_UNCHECKED);
029
030 /** External checking. */
031 public static final LogicalModuleState STATE_EXTERNAL_CHECKING
032 = new LogicalModuleState(LogicalModuleStateDescriptions.STATE_STRING_EXTERNAL_CHECKING,
033 false, LogicalModuleStateDescriptions.STATE_CODE_EXTERNAL_CHECKING);
034
035 /** External checking failed. */
036 public static final LogicalModuleState STATE_EXTERNAL_CHECKING_FAILED
037 = new LogicalModuleState(LogicalModuleStateDescriptions.STATE_STRING_EXTERNAL_CHECKING_FAILED,
038 true, LogicalModuleStateDescriptions.STATE_CODE_EXTERNAL_CHECKING_FAILED);
039
040 /** Internal checking phase. */
041 public static final LogicalModuleState STATE_INTERNAL_CHECKING
042 = new LogicalModuleState(LogicalModuleStateDescriptions.STATE_STRING_INTERNAL_CHECKING,
043 false, LogicalModuleStateDescriptions.STATE_CODE_INTERNAL_CHECKING);
044
045 /** Internal check failed. */
046 public static final LogicalModuleState STATE_INTERNAL_CHECKING_FAILED
047 = new LogicalModuleState(LogicalModuleStateDescriptions.STATE_STRING_INTERNAL_CHECKING_FAILED,
048 true, LogicalModuleStateDescriptions.STATE_CODE_INTERNAL_CHECKING_FAILED);
049
050
051 /** Successfully completely checked. */
052 public static final LogicalModuleState STATE_CHECKED
053 = new LogicalModuleState(LogicalModuleStateDescriptions.STATE_STRING_COMPLETELY_CHECKED,
054 false, LogicalModuleStateDescriptions.STATE_CODE_COMPLETELY_CHECKED);
055
056
057 /** meaning of this state. */
058 private final String text;
059
060 /** is this state a failure? */
061 private final boolean failure;
062
063 /** Code for state. */
064 private final int code;
065
066 /**
067 * Creates new module state.
068 *
069 * @param text meaning of this state, <code>null</code> is not permitted.
070 * @param failure is this a failure state?
071 * @param code code of this state.
072 * @throws IllegalArgumentException text == <code>null</code>
073 */
074 private LogicalModuleState(final String text, final boolean failure, final int code) {
075 this.text = text;
076 if (this.text == null) {
077 throw new IllegalArgumentException("text==null");
078 }
079 this.failure = failure;
080 this.code = code;
081 }
082
083 public String getText() {
084 return this.text;
085 }
086
087 public boolean isFailure() {
088 return this.failure;
089 }
090
091 public int getCode() {
092 return this.code;
093 }
094
095 public String toString() {
096 return this.text;
097 }
098
099 public int hashCode() {
100 return this.text.hashCode();
101 }
102
103 public boolean equals(final Object obj) {
104 // every instance is unique
105 return (this == obj);
106 }
107
108 }
|