Commit 1f022fc1 authored by Mihai Nita's avatar Mihai Nita

Merged in revert-pr-8 (pull request #10)

Revert "Issue 22 incorrect equals() method in Tag and derived classes (pull request #8)"
parents f2d8b610 eefe6580
......@@ -102,12 +102,12 @@ public class CTag extends Tag {
}
@Override
public boolean equals (Object other) {
if ( other == null ) return false;
if ( this == other ) return true;
if ( !(other instanceof CTag) ) return false;
public boolean equals (Tag tag) {
if ( tag == null ) return false;
if ( this == tag ) return true;
if ( !(tag instanceof CTag) ) return false;
CTag ctag = (CTag)other;
CTag ctag = (CTag)tag;
if ( tagType.compareTo(ctag.getTagType()) != 0 ) return false;
if ( Util.compareAllowingNull(getId(), ctag.getId()) != 0 ) return false;
......@@ -443,8 +443,4 @@ public class CTag extends Tag {
}
}
@Override
public int hashCode() {
return cc.hashCode() + data.hashCode() + String.valueOf(initialWithData).hashCode() + dataRef.hashCode() + dataDir.hashCode() + disp.hashCode() + equiv.hashCode() + subFlows.hashCode() + canReorder.hashCode();
}
}
......@@ -155,11 +155,11 @@ public class MTag extends Tag implements IWithITSAttributes {
}
@Override
public boolean equals (Object other) {
if ( other == null ) return false;
if ( this == other ) return true;
if ( !(other instanceof MTag) ) return false;
MTag mtag = (MTag)other;
public boolean equals (Tag tag) {
if ( tag == null ) return false;
if ( this == tag ) return true;
if ( !(tag instanceof MTag) ) return false;
MTag mtag = (MTag)tag;
if ( tagType.compareTo(mtag.getTagType()) != 0 ) return false;
return mc.equals(mtag.mc);
}
......@@ -189,8 +189,4 @@ public class MTag extends Tag implements IWithITSAttributes {
mc.setITSItems(itsItems);
}
@Override
public int hashCode() {
return mc.hashCode() + tagType.hashCode();
}
}
......@@ -24,7 +24,7 @@ import net.sf.okapi.lib.xliff2.its.IWithITSAttributes;
/**
* Represents common data for the opening and closing {@link MTag}.
*/
public class MTagCommon implements IWithITSAttributes {
class MTagCommon implements IWithITSAttributes {
private String id;
private String type;
......
......@@ -86,13 +86,12 @@ abstract public class Tag extends DataWithExtAttributes {
abstract public void setType (String type);
/**
* Indicates if this other is equal to another.
* Indicates if this tag is equal to another.
* <p>Use the <code>==</code> operator to test if two tags are the same.
* @param other the other tag to compare to this one.
* @param tag the other tag to compare to this one.
* @return true if both tags are equals.
*/
@Override
public abstract boolean equals(Object other);
abstract boolean equals (Tag tag);
/**
* Indicates if this tag is for a marker ({@link MTag}).
......
......@@ -233,18 +233,4 @@ public class TermTag extends MTag {
setValue(null);
}
@Override
public boolean equals (Object other) {
if ( other == null ) return false;
if ( this == other) return true;
if ( !(other instanceof TermTag) ) return false;
TermTag termtag = (TermTag) other;
if ( tagType.compareTo(termtag.getTagType()) != 0 ) return false;
return mc.equals(termtag.mc);
}
@Override
public int hashCode() {
return super.hashCode() + annotatorRef.hashCode() + termConfidence.hashCode();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment