discovering Java programming
Nov. 18th, 2016 11:12 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
/** * A marker interface for classes that have no data inside * Meaning, two instances are equal if they have the same class */ public interface JustCode extends Serializable { } ... public interface Function<X, Y> extends JustCode { Y apply(X x); } ... public interface Function2<X, Y, Z> extends JustCode { Z apply(X x, Y y); } ... public int hashCode(JustCode x) { return x == null ? 0 : x.getClass().hashCode(); } public boolean equal(JustCode x, JustCode y) { return x == null ? y == null : y != null && x.getClass() == y.getClass(); }
No shit, just discovered this kind of data.
You've probably noticed that I kind of prefer
S
to OOP. :)