juan_gandhi: (VP)
[personal profile] juan_gandhi
/**
 * 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. :)
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 1920 21
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 24th, 2025 10:42 am
Powered by Dreamwidth Studios