MCPcopy Create free account
hub / github.com/GateNLP/gate-core / equals

Method equals

src/main/java/gate/annotation/AnnotationImpl.java:126–177  ·  view source on GitHub ↗

Returns true if two annotation are Equals. Two Annotation are equals if their offsets, types, id and features are the same.

(Object obj)

Source from the content-addressed store, hash-verified

124 * same.
125 */
126 @Override
127 public boolean equals(Object obj){
128 if(obj == null)
129 return false;
130 Annotation other;
131 if(obj instanceof AnnotationImpl){
132 other = (Annotation) obj;
133 }else return false;
134
135 // If their types are not equals then return false
136 if((type == null) ^ (other.getType() == null))
137 return false;
138 if(type != null && (!type.equals(other.getType())))
139 return false;
140
141 // If their types are not equals then return false
142 if((id == null) ^ (other.getId() == null))
143 return false;
144 if((id != null )&& (!id.equals(other.getId())))
145 return false;
146
147 // If their start offset is not the same then return false
148 if((start == null) ^ (other.getStartNode() == null))
149 return false;
150 if(start != null){
151 if((start.getOffset() == null) ^
152 (other.getStartNode().getOffset() == null))
153 return false;
154 if(start.getOffset() != null &&
155 (!start.getOffset().equals(other.getStartNode().getOffset())))
156 return false;
157 }
158
159 // If their end offset is not the same then return false
160 if((end == null) ^ (other.getEndNode() == null))
161 return false;
162 if(end != null){
163 if((end.getOffset() == null) ^
164 (other.getEndNode().getOffset() == null))
165 return false;
166 if(end.getOffset() != null &&
167 (!end.getOffset().equals(other.getEndNode().getOffset())))
168 return false;
169 }
170
171 // If their featureMaps are not equals then return false
172 if((features == null) ^ (other.getFeatures() == null))
173 return false;
174 if(features != null && (!features.equals(other.getFeatures())))
175 return false;
176 return true;
177 }// equals
178
179 /** Set the feature set. Overriden from the implementation in
180 * AbstractFeatureBearer because it needs to fire events

Callers

nothing calls this directly

Calls 7

getTypeMethod · 0.65
equalsMethod · 0.65
getIdMethod · 0.65
getStartNodeMethod · 0.65
getOffsetMethod · 0.65
getEndNodeMethod · 0.65
getFeaturesMethod · 0.65

Tested by

no test coverage detected