Fix implementation of equals for BaseTypeReference

This fixes the implementation so it matches what is described in the
documentation for the TypeReference interface. Specifically, it allows
for comparison to a CharSequence
This commit is contained in:
Ben Gruver 2013-04-17 00:12:20 -07:00
parent 36b6a31685
commit dda097947f
2 changed files with 8 additions and 3 deletions

View File

@ -43,8 +43,13 @@ public abstract class BaseTypeReference implements TypeReference {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o != null && o instanceof TypeReference) { if (o != null) {
return getType().equals(((TypeReference)o).getType()); if (o instanceof TypeReference) {
return getType().equals(((TypeReference)o).getType());
}
if (o instanceof CharSequence) {
return getType().equals(o.toString());
}
} }
return false; return false;
} }

View File

@ -69,7 +69,7 @@ public interface TypeReference extends Reference, CharSequence, Comparable<CharS
/** /**
* Compares this TypeReference to another TypeReference, or more generally to another CharSequence for equality. * Compares this TypeReference to another TypeReference, or more generally to another CharSequence for equality.
* *
* This TypeReference is equal to a CharSequence iff this.getType().equals(other.getString()). * This TypeReference is equal to a CharSequence iff this.getType().equals(other.toString()).
* *
* Equivalently, This TypeReference is equal to another TypeReference iff this.getType().equals(other.getType()). * Equivalently, This TypeReference is equal to another TypeReference iff this.getType().equals(other.getType()).
* *