public class Equals { private Equals() {} public staticUsage example:boolean of(Class type, Object obj, Predicate pred) { if (obj == null) { return false; } if (!type.isInstance(obj)) { return false; } T other = type.cast(obj); return pred.test(other); } }
@Override public boolean equals(Object obj) { return Equals.of(ClassKey.class, obj, other -> Objects.equals(this.kind, other.kind) && Objects.equals(this.obj, other.obj) ); }