1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.qedeq.kernel.bo.module; |
19 |
|
|
20 |
|
import java.util.HashMap; |
21 |
|
import java.util.Map; |
22 |
|
|
23 |
|
import org.qedeq.base.trace.Trace; |
24 |
|
import org.qedeq.kernel.base.module.FunctionDefinition; |
25 |
|
import org.qedeq.kernel.base.module.PredicateDefinition; |
26 |
|
import org.qedeq.kernel.bo.logic.wf.ExistenceChecker; |
27 |
|
import org.qedeq.kernel.bo.logic.wf.Function; |
28 |
|
import org.qedeq.kernel.bo.logic.wf.HigherLogicalErrors; |
29 |
|
import org.qedeq.kernel.bo.logic.wf.Predicate; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@author |
37 |
|
|
|
|
| 83,8% |
Uncovered Elements: 11 (68) |
Complexity: 21 |
Complexity Density: 0,49 |
|
38 |
|
public class DefaultExistenceChecker implements ExistenceChecker { |
39 |
|
|
40 |
|
|
41 |
|
private static final Class CLASS = DefaultExistenceChecker.class; |
42 |
|
|
43 |
|
@link@link |
44 |
|
private final Map predicateDefinitions = new HashMap(); |
45 |
|
|
46 |
|
@link@link |
47 |
|
private final Map functionDefinitions = new HashMap(); |
48 |
|
|
49 |
|
|
50 |
|
private boolean setDefinitionByFormula; |
51 |
|
|
52 |
|
|
53 |
|
private boolean identityOperatorDefined; |
54 |
|
|
55 |
|
|
56 |
|
private String identityOperator; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
63
|
public DefaultExistenceChecker() {... |
63 |
63
|
clear(); |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
69 |
125
|
public void clear() {... |
70 |
125
|
Trace.trace(CLASS, this, "setClassOperatorExists", "clear"); |
71 |
125
|
predicateDefinitions.clear(); |
72 |
125
|
functionDefinitions.clear(); |
73 |
125
|
identityOperatorDefined = false; |
74 |
125
|
identityOperator = null; |
75 |
125
|
setDefinitionByFormula = false; |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@param |
82 |
|
@return |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
84 |
168
|
public boolean predicateExists(final Predicate predicate) {... |
85 |
168
|
final PredicateDefinition definition = (PredicateDefinition) predicateDefinitions |
86 |
|
.get(predicate); |
87 |
168
|
return null != definition; |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
90 |
3172
|
public boolean predicateExists(final String name, final int arguments) {... |
91 |
3172
|
final Predicate predicate = new Predicate(name, "" + arguments); |
92 |
3172
|
final PredicateDefinition definition = (PredicateDefinition) predicateDefinitions |
93 |
|
.get(predicate); |
94 |
3172
|
return null != definition; |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
@param |
102 |
|
|
103 |
|
@throws |
104 |
|
|
|
|
| 66,7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
105 |
168
|
public void add(final PredicateDefinition definition) {... |
106 |
168
|
final Predicate predicate = new Predicate(definition.getName(), |
107 |
|
definition.getArgumentNumber()); |
108 |
168
|
if (predicateDefinitions.get(predicate) != null) { |
109 |
0
|
throw new IllegalArgumentException(HigherLogicalErrors.PREDICATE_ALREADY_DEFINED_TEXT |
110 |
|
+ predicate); |
111 |
|
} |
112 |
168
|
predicateDefinitions.put(predicate, definition); |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
@param |
119 |
|
@return |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
344
|
public PredicateDefinition get(final Predicate predicate) {... |
122 |
344
|
return (PredicateDefinition) predicateDefinitions.get(predicate); |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
@param |
129 |
|
@param |
130 |
|
@return |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
132 |
344
|
public PredicateDefinition getPredicate(final String name, final int arguments) {... |
133 |
344
|
final Predicate predicate = new Predicate(name, "" + arguments); |
134 |
344
|
return get(predicate); |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
@param |
141 |
|
@return |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
143 |
96
|
public boolean functionExists(final Function function) {... |
144 |
96
|
final FunctionDefinition definition = (FunctionDefinition) functionDefinitions |
145 |
|
.get(function); |
146 |
96
|
return null != definition; |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
149 |
1440
|
public boolean functionExists(final String name, final int arguments) {... |
150 |
1440
|
final Function function = new Function(name, "" + arguments); |
151 |
1440
|
final FunctionDefinition definition = (FunctionDefinition) functionDefinitions |
152 |
|
.get(function); |
153 |
1440
|
return null != definition; |
154 |
|
} |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
@param |
161 |
|
|
162 |
|
@throws |
163 |
|
|
|
|
| 66,7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
164 |
96
|
public void add(final FunctionDefinition definition) {... |
165 |
96
|
final Function function = new Function(definition.getName(), |
166 |
|
definition.getArgumentNumber()); |
167 |
96
|
if (functionDefinitions.get(function) != null) { |
168 |
0
|
throw new IllegalArgumentException(HigherLogicalErrors.FUNCTION_ALREADY_DEFINED_TEXT |
169 |
|
+ function); |
170 |
|
} |
171 |
96
|
functionDefinitions.put(function, definition); |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
@param |
178 |
|
@return |
179 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
180 |
0
|
public FunctionDefinition get(final Function function) {... |
181 |
0
|
return (FunctionDefinition) functionDefinitions.get(function); |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
@param |
188 |
|
@param |
189 |
|
@return |
190 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
191 |
0
|
public FunctionDefinition getFunction(final String name, final int arguments) {... |
192 |
0
|
final Function function = new Function(name, "" + arguments); |
193 |
0
|
return get(function); |
194 |
|
} |
195 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
196 |
228
|
public boolean classOperatorExists() {... |
197 |
228
|
return setDefinitionByFormula; |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
@param |
204 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
205 |
68
|
public void setClassOperatorExists(final boolean existence) {... |
206 |
68
|
Trace.param(CLASS, this, "setClassOperatorExists", "existence", existence); |
207 |
68
|
setDefinitionByFormula = existence; |
208 |
|
} |
209 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
210 |
1520
|
public boolean equalityOperatorExists() {... |
211 |
1520
|
return identityOperatorDefined; |
212 |
|
} |
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
@param |
218 |
|
@param |
219 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
220 |
79
|
public void setIdentityOperatorDefined(final boolean defined, final String identityOperator) {... |
221 |
79
|
Trace.param(CLASS, this, "setIdentityOperatorDefined", "defined", defined); |
222 |
79
|
this.identityOperatorDefined = defined; |
223 |
79
|
if (defined) { |
224 |
37
|
this.identityOperator = identityOperator; |
225 |
|
} else { |
226 |
42
|
this.identityOperator = null; |
227 |
|
} |
228 |
|
} |
229 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
230 |
674
|
public String getIdentityOperator() {... |
231 |
674
|
if (!equalityOperatorExists()) { |
232 |
0
|
return null; |
233 |
|
} |
234 |
674
|
return this.identityOperator; |
235 |
|
} |
236 |
|
|
237 |
|
} |