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.dto.module;
017
018 import org.qedeq.base.utility.EqualsUtility;
019 import org.qedeq.kernel.se.base.module.Axiom;
020 import org.qedeq.kernel.se.base.module.ChangedRuleList;
021 import org.qedeq.kernel.se.base.module.FunctionDefinition;
022 import org.qedeq.kernel.se.base.module.InitialFunctionDefinition;
023 import org.qedeq.kernel.se.base.module.InitialPredicateDefinition;
024 import org.qedeq.kernel.se.base.module.LatexList;
025 import org.qedeq.kernel.se.base.module.LinkList;
026 import org.qedeq.kernel.se.base.module.PredicateDefinition;
027 import org.qedeq.kernel.se.base.module.ProofList;
028 import org.qedeq.kernel.se.base.module.Proposition;
029 import org.qedeq.kernel.se.base.module.Rule;
030
031
032 /**
033 * Rule declaration.
034 *
035 * @author Michael Meyling
036 */
037 public class RuleVo implements Rule {
038
039 /** List of necessary ids. */
040 private LinkListVo linkList;
041
042 /** Description. */
043 private LatexList description;
044
045 /** Rule name. */
046 private String name;
047
048 /** Rule version. */
049 private String version;
050
051 /** This rule changes the list of following rules. */
052 private ChangedRuleListVo changedRuleList;
053
054 /** Proofs for this rule. */
055 private ProofListVo proofList;
056
057 /**
058 * Constructs a new rule declaration.
059 */
060 public RuleVo() {
061 // nothing to do
062 }
063
064 public Axiom getAxiom() {
065 return null;
066 }
067
068 public InitialPredicateDefinition getInitialPredicateDefinition() {
069 return null;
070 }
071
072 public PredicateDefinition getPredicateDefinition() {
073 return null;
074 }
075
076 public InitialFunctionDefinition getInitialFunctionDefinition() {
077 return null;
078 }
079
080 public FunctionDefinition getFunctionDefinition() {
081 return null;
082 }
083
084 public Proposition getProposition() {
085 return null;
086 }
087
088 public Rule getRule() {
089 return this;
090 }
091
092 /**
093 * Set rule name.
094 *
095 * @param name Rule name.
096 */
097 public final void setName(final String name) {
098 this.name = name;
099 }
100
101 public final String getName() {
102 return name;
103 }
104
105 /**
106 * Set rule version.
107 *
108 * @param version Rule version.
109 */
110 public final void setVersion(final String version) {
111 this.version = version;
112 }
113
114 public final String getVersion() {
115 return version;
116 }
117
118 /**
119 * Set list of necessary ids.
120 *
121 * @param linkList List.
122 */
123 public final void setLinkList(final LinkListVo linkList) {
124 this.linkList = linkList;
125 }
126
127 public final LinkList getLinkList() {
128 return linkList;
129 }
130
131 /**
132 * Add link for this rule.
133 *
134 * @param id Id to add.
135 */
136 public final void addLink(final String id) {
137 if (linkList == null) {
138 linkList = new LinkListVo();
139 }
140 linkList.add(id);
141 }
142
143 /**
144 * Set description.
145 *
146 * @param description Description.
147 */
148 public final void setDescription(final LatexListVo description) {
149 this.description = description;
150 }
151
152 public LatexList getDescription() {
153 return description;
154 }
155
156 /**
157 * Set rule proof list.
158 *
159 * @param proofList Proof list.
160 */
161 public final void setProofList(final ProofListVo proofList) {
162 this.proofList = proofList;
163 }
164
165 public final ProofList getProofList() {
166 return proofList;
167 }
168
169 /**
170 * Add proof to this list.
171 *
172 * @param proof Proof to add.
173 */
174 public final void addProof(final ProofVo proof) {
175 if (proofList == null) {
176 proofList = new ProofListVo();
177 }
178 proofList.add(proof);
179 }
180
181 /**
182 * Set list of changed rules.
183 *
184 * @param changedRuleList List of changed rules.
185 */
186 public final void setChangedRuleList(final ChangedRuleListVo changedRuleList) {
187 this.changedRuleList = changedRuleList;
188 }
189
190 public final ChangedRuleList getChangedRuleList() {
191 return changedRuleList;
192 }
193
194 /**
195 * Add changed rule to this list.
196 *
197 * @param changedRule Changed rule to add.
198 */
199 public final void addChangedRule(final ChangedRuleVo changedRule) {
200 if (changedRuleList == null) {
201 changedRuleList = new ChangedRuleListVo();
202 }
203 changedRuleList.add(changedRule);
204 }
205
206 public boolean equals(final Object obj) {
207 if (!(obj instanceof RuleVo)) {
208 return false;
209 }
210 final RuleVo other = (RuleVo) obj;
211 return EqualsUtility.equals(getName(), other.getName())
212 && EqualsUtility.equals(getVersion(), other.getVersion())
213 && EqualsUtility.equals(getLinkList(), other.getLinkList())
214 && EqualsUtility.equals(getDescription(), other.getDescription())
215 && EqualsUtility.equals(getChangedRuleList(), other.getChangedRuleList())
216 && EqualsUtility.equals(getProofList(), other.getProofList());
217 }
218
219 public int hashCode() {
220 return (getName() != null ? 1 ^ getName().hashCode() : 0)
221 ^ (getVersion() != null ? 2 ^ getVersion().hashCode() : 0)
222 ^ (getLinkList() != null ? 3 ^ getLinkList().hashCode() : 0)
223 ^ (getDescription() != null ? 4 ^ getDescription().hashCode() : 0)
224 ^ (getChangedRuleList() != null ? 5 ^ getChangedRuleList().hashCode() : 0)
225 ^ (getProofList() != null ? 6 ^ getProofList().hashCode() : 0);
226 }
227
228 public String toString() {
229 final StringBuffer buffer = new StringBuffer();
230 buffer.append("Rule: " + getName() + " [" + getVersion() + "]\n");
231 buffer.append(getLinkList());
232 buffer.append("\nDescription:\n");
233 buffer.append(getDescription());
234 buffer.append(getProofList());
235 buffer.append(getChangedRuleList());
236 return buffer.toString();
237 }
238 }
|