Remove need in equals() for explicit type

This commit is contained in:
Paul Campbell 2017-12-09 17:23:14 +00:00
parent d93f27d959
commit f49df2d895

View file

@ -75,11 +75,11 @@ public abstract class TypeAlias<T> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final boolean equals(final Object o) { public final boolean equals(final Object o) {
if (o instanceof TypeAlias) { if (o instanceof TypeAlias) {
if (((TypeAlias) o).type.equals(type)) { final TypeAlias other = (TypeAlias) o;
return ((TypeAlias<T>) o).map(getValue()::equals); final Object otherValue = other.getValue();
} else { final Class<?> otherValueClass = otherValue.getClass();
return false; return otherValueClass.equals(getValue().getClass())
} && otherValue.equals(getValue());
} }
return map(o::equals); return map(o::equals);
} }