Match cloned = null;
try {
cloned = (Match) super.clone();
+ cloned.matches = matches;
cloned.fields = new HashMap<MatchType, MatchField>();
for (Entry<MatchType, MatchField> entry : this.fields.entrySet()) {
cloned.fields.put(entry.getKey(), entry.getValue().clone());
Match reverse = this.clone();
// Flip symmetric fields
- for (Map.Entry<MatchType, MatchType> entry : Match.reversableMatches
- .entrySet()) {
+ for (Map.Entry<MatchType, MatchType> entry : Match.reversableMatches.entrySet()) {
MatchType from = entry.getKey();
MatchType to = entry.getValue();
if (this.isPresent(from)) {
- reverse.setField(to, this.getField(from).getValue(), this
- .getField(from).getMask());
+ reverse.setField(to, this.getField(from).getValue(), this.getField(from).getMask());
+ if (!this.isPresent(to)) {
+ reverse.clearField(from);
+ }
}
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Match other = (Match) obj;
if (fields == null) {
- if (other.fields != null)
+ if (other.fields != null) {
return false;
- } else if (!fields.equals(other.fields))
+ }
+ } else if (!fields.equals(other.fields)) {
return false;
- if (matches != other.matches)
+ }
+ if (matches != other.matches) {
return false;
+ }
return true;
}