1 | /* This file is part of the project "Hilbert II" - http://www.qedeq.org |
2 | * |
3 | * Copyright 2000-2014, Michael Meyling <mime@qedeq.org>. |
4 | * |
5 | * "Hilbert II" is free software; you can redistribute |
6 | * it and/or modify it under the terms of the GNU General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
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.se.dto.module; |
17 | |
18 | import org.qedeq.base.utility.EqualsUtility; |
19 | import org.qedeq.kernel.se.base.module.Axiom; |
20 | import org.qedeq.kernel.se.base.module.ChangedRuleList; |
21 | import org.qedeq.kernel.se.base.module.FunctionDefinition; |
22 | import org.qedeq.kernel.se.base.module.InitialFunctionDefinition; |
23 | import org.qedeq.kernel.se.base.module.InitialPredicateDefinition; |
24 | import org.qedeq.kernel.se.base.module.LatexList; |
25 | import org.qedeq.kernel.se.base.module.LinkList; |
26 | import org.qedeq.kernel.se.base.module.PredicateDefinition; |
27 | import org.qedeq.kernel.se.base.module.ProofList; |
28 | import org.qedeq.kernel.se.base.module.Proposition; |
29 | import org.qedeq.kernel.se.base.module.Rule; |
30 | |
31 | |
32 | /** |
33 | * Rule declaration. |
34 | * |
35 | * @author Michael Meyling |
36 | */ |
37 | public class RuleVo implements Rule { |
38 | |
39 | /** List of necessary ids. */ |
40 | private LinkListVo linkList; |
41 | |
42 | /** Description. */ |
43 | private LatexList description; |
44 | |
45 | /** Rule name. */ |
46 | private String name; |
47 | |
48 | /** Rule version. */ |
49 | private String version; |
50 | |
51 | /** This rule changes the list of following rules. */ |
52 | private ChangedRuleListVo changedRuleList; |
53 | |
54 | /** Proofs for this rule. */ |
55 | private ProofListVo proofList; |
56 | |
57 | /** |
58 | * Constructs a new rule declaration. |
59 | */ |
60 | public RuleVo() { |
61 | // nothing to do |
62 | } |
63 | |
64 | public Axiom getAxiom() { |
65 | return null; |
66 | } |
67 | |
68 | public InitialPredicateDefinition getInitialPredicateDefinition() { |
69 | return null; |
70 | } |
71 | |
72 | public PredicateDefinition getPredicateDefinition() { |
73 | return null; |
74 | } |
75 | |
76 | public InitialFunctionDefinition getInitialFunctionDefinition() { |
77 | return null; |
78 | } |
79 | |
80 | public FunctionDefinition getFunctionDefinition() { |
81 | return null; |
82 | } |
83 | |
84 | public Proposition getProposition() { |
85 | return null; |
86 | } |
87 | |
88 | public Rule getRule() { |
89 | return this; |
90 | } |
91 | |
92 | /** |
93 | * Set rule name. |
94 | * |
95 | * @param name Rule name. |
96 | */ |
97 | public final void setName(final String name) { |
98 | this.name = name; |
99 | } |
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 | } |