1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.qedeq.kernel.bo.logic.common;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.qedeq.base.utility.EqualsUtility;
22 import org.qedeq.kernel.se.base.list.ElementList;
23 import org.qedeq.kernel.se.common.ModuleContext;
24
25
26
27
28
29
30 public final class PredicateConstant {
31
32
33 private final PredicateKey key;
34
35
36 private final ElementList completeFormula;
37
38
39 private final ModuleContext context;
40
41
42 private final ElementList predicate;
43
44
45 private final ElementList definingFormula;
46
47
48 private final List subjectVariables;
49
50
51
52
53
54
55
56
57
58 public PredicateConstant(final PredicateKey key, final ElementList completeFormula,
59 final ModuleContext context) {
60 this.key = key;
61 this.completeFormula = completeFormula;
62 this.context = new ModuleContext(context);
63 final ElementList list = completeFormula.getList();
64 predicate = list.getElement(0).getList();
65 definingFormula = list.getElement(1).getList();
66 subjectVariables = new ArrayList(predicate.size() - 1);
67 for (int i = 0; i < predicate.size() - 1; i++) {
68 subjectVariables.add(new SubjectVariable(
69 predicate.getElement(i + 1).getList().getElement(0).getAtom().getString()));
70 }
71 }
72
73
74
75
76
77
78 public PredicateKey getKey() {
79 return key;
80 }
81
82
83
84
85
86
87 public String getName() {
88 return key.getName();
89 }
90
91
92
93
94
95
96 public String getArguments() {
97 return key.getArguments();
98 }
99
100
101
102
103
104
105 public ElementList getCompleteFormula() {
106 return completeFormula;
107 }
108
109
110
111
112
113
114 public ModuleContext getContext() {
115 return context;
116 }
117
118
119
120
121
122
123 public ElementList getPredicate() {
124 return predicate;
125 }
126
127
128
129
130
131
132 public List getSubjectVariables() {
133 return subjectVariables;
134 }
135
136
137
138
139
140
141 public ElementList getDefiningFormula() {
142 return definingFormula;
143 }
144
145 public int hashCode() {
146 return (getKey() != null ? getKey().hashCode() : 0)
147 ^ (getCompleteFormula() != null ? getCompleteFormula().hashCode() : 0);
148 }
149
150 public boolean equals(final Object obj) {
151 if (!(obj instanceof PredicateConstant)) {
152 return false;
153 }
154 final PredicateConstant other = (PredicateConstant) obj;
155 return EqualsUtility.equals(getKey(), other.getKey())
156 && EqualsUtility.equals(getCompleteFormula(), other.getCompleteFormula());
157 }
158
159 public String toString() {
160 return getName() + "[" + getArguments() + "]";
161 }
162
163
164 }