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.list.Element; |
20 | import org.qedeq.kernel.se.base.module.Axiom; |
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.PredicateDefinition; |
26 | import org.qedeq.kernel.se.base.module.Proposition; |
27 | import org.qedeq.kernel.se.base.module.Rule; |
28 | |
29 | |
30 | /** |
31 | * Definition of function operator. This is a function constant. For example the function |
32 | * "x union y" or constants like the empty set. |
33 | * |
34 | * @author Michael Meyling |
35 | */ |
36 | public class InitialFunctionDefinitionVo implements InitialFunctionDefinition { |
37 | |
38 | /** Carries information about the argument number the defined object needs. */ |
39 | private String argumentNumber; |
40 | |
41 | /** This name together with argumentNumber identifies a function. */ |
42 | private String name; |
43 | |
44 | /** LaTeX pattern for definition visualisation. The replaceable arguments must are |
45 | * marked as <code>#1</code>, <code>#2</code> and so on. For example |
46 | * <code>\mathfrak{M}(#1)</code> */ |
47 | private String latexPattern; |
48 | |
49 | /** Defined function constant with free subject variables as arguments. */ |
50 | private Element funCon; |
51 | |
52 | /** Further proposition description. Normally <code>null</code>. */ |
53 | private LatexList description; |
54 | |
55 | /** |
56 | * Constructs a new definition. |
57 | */ |
58 | public InitialFunctionDefinitionVo() { |
59 | // nothing to do |
60 | } |
61 | |
62 | public Axiom getAxiom() { |
63 | return null; |
64 | } |
65 | |
66 | public InitialPredicateDefinition getInitialPredicateDefinition() { |
67 | return null; |
68 | } |
69 | |
70 | public PredicateDefinition getPredicateDefinition() { |
71 | return null; |
72 | } |
73 | |
74 | public InitialFunctionDefinition getInitialFunctionDefinition() { |
75 | return this; |
76 | } |
77 | |
78 | public FunctionDefinition getFunctionDefinition() { |
79 | return null; |
80 | } |
81 | |
82 | public Proposition getProposition() { |
83 | return null; |
84 | } |
85 | |
86 | public Rule getRule() { |
87 | return null; |
88 | } |
89 | |
90 | /** |
91 | * Set information about the argument number the defined object needs. |
92 | * |
93 | * @param argumentNumber Argument number information. |
94 | */ |
95 | public final void setArgumentNumber(final String argumentNumber) { |
96 | this.argumentNumber = argumentNumber; |
97 | } |
98 | |
99 | public final String getArgumentNumber() { |
100 | return argumentNumber; |
101 | } |
102 | |
103 | /** |
104 | * Set function name. Together with {@link #getArgumentNumber()} this |
105 | * identifies a function. |
106 | * |
107 | * @param name Function name. |
108 | */ |
109 | public void setName(final String name) { |
110 | this.name = name; |
111 | } |
112 | |
113 | public String getName() { |
114 | return name; |
115 | } |
116 | |
117 | /** |
118 | * Set LaTeX pattern for definition visualisation. The replaceable arguments are |
119 | * marked as <code>#1</code>, <code>#2</code> and so on. For example |
120 | * <code>\mathfrak{M}(#1)</code>. |
121 | * |
122 | * @param latexPattern LaTeX pattern for definition visualisation. |
123 | */ |
124 | public final void setLatexPattern(final String latexPattern) { |
125 | this.latexPattern = latexPattern; |
126 | } |
127 | |
128 | public final String getLatexPattern() { |
129 | return latexPattern; |
130 | } |
131 | |
132 | public Element getFunCon() { |
133 | return funCon; |
134 | } |
135 | |
136 | /** |
137 | * Set function constant that we define. The function constant must |
138 | * match {@link #getName()} and {@link #getArgumentNumber()}. |
139 | * |
140 | * @param funCon Function constant with free subject variables as arguments. |
141 | */ |
142 | public void setFunCon(final Element funCon) { |
143 | this.funCon = funCon; |
144 | } |
145 | |
146 | /** |
147 | * Set description. Only necessary if formula is not self-explanatory. |
148 | * |
149 | * @param description Description. |
150 | */ |
151 | public final void setDescription(final LatexListVo description) { |
152 | this.description = description; |
153 | } |
154 | |
155 | public LatexList getDescription() { |
156 | return description; |
157 | } |
158 | |
159 | public boolean equals(final Object obj) { |
160 | if (!(obj instanceof InitialFunctionDefinition)) { |
161 | return false; |
162 | } |
163 | final InitialFunctionDefinition other = (InitialFunctionDefinition) obj; |
164 | return EqualsUtility.equals(getArgumentNumber(), other.getArgumentNumber()) |
165 | && EqualsUtility.equals(getName(), other.getName()) |
166 | && EqualsUtility.equals(getLatexPattern(), other.getLatexPattern()) |
167 | && EqualsUtility.equals(getFunCon(), other.getFunCon()) |
168 | && EqualsUtility.equals(getDescription(), other.getDescription()); |
169 | } |
170 | |
171 | public int hashCode() { |
172 | return (getArgumentNumber() != null ? getArgumentNumber().hashCode() : 0) |
173 | ^ (getName() != null ? 1 ^ getName().hashCode() : 0) |
174 | ^ (getLatexPattern() != null ? 2 ^ getLatexPattern().hashCode() : 0) |
175 | ^ (getFunCon() != null ? 3 ^ getFunCon().hashCode() : 0) |
176 | ^ (getDescription() != null ? 5 ^ getDescription().hashCode() : 0); |
177 | } |
178 | |
179 | public String toString() { |
180 | final StringBuffer buffer = new StringBuffer(); |
181 | buffer.append("Initial Function Definition arguments=" + getArgumentNumber() + "\n"); |
182 | buffer.append("\tname=" + getName() + "\n"); |
183 | buffer.append("\tpattern=" + getLatexPattern() + "\n"); |
184 | buffer.append("\tfuncon=" + getFunCon() + "\n"); |
185 | buffer.append("\tdescription:\n" + getDescription() + "\n"); |
186 | return buffer.toString(); |
187 | } |
188 | |
189 | } |