TypeAlias: access own member fields directly

This commit is contained in:
Paul Campbell 2018-07-05 07:27:17 +01:00
parent f0f8ba6a9b
commit 7648967f8a

View file

@ -59,29 +59,28 @@ public abstract class TypeAlias<T> {
* @return a TypeAlias * @return a TypeAlias
*/ */
public final <R> R map(final Function<T, R> f) { public final <R> R map(final Function<T, R> f) {
return f.apply(getValue()); return f.apply(value);
} }
@Override @Override
public final int hashCode() { public final int hashCode() {
return getValue().hashCode(); return value.hashCode();
} }
@Override @Override
public final boolean equals(final Object o) { public final boolean equals(final Object o) {
if (o instanceof TypeAlias) { if (o instanceof TypeAlias) {
final TypeAlias other = (TypeAlias) o; final TypeAlias other = (TypeAlias) o;
final Object otherValue = other.getValue(); final Class<?> otherValueClass = other.value.getClass();
final Class<?> otherValueClass = otherValue.getClass();
return otherValueClass.equals(getValue().getClass()) return otherValueClass.equals(getValue().getClass())
&& otherValue.equals(getValue()); && other.value.equals(getValue());
} }
return map(o::equals); return map(o::equals);
} }
@Override @Override
public final String toString() { public final String toString() {
return getValue().toString(); return value.toString();
} }
/** /**