How to implement Box.equals
    Boaz Nahum 
    boaznahum at gmail.com
       
    Fri Aug 14 14:15:53 UTC 2015
    
    
  
How can one implement something simple as Box.eqauls
I tried:
public class PSupport {
    static boolean equals(boolean x, boolean y) { return x == y;}
    static boolean equals(int x, byte y) { return x == y;}
    static boolean equals(char x, char y) { return x == y;}
    static boolean equals(short x, short y) { return x == y;}
    static boolean equals(int x, int y) { return x == y;}
    static boolean equals(long x, long y) { return x == y;}
    static boolean equals(float x, float y) { return x == y;}
    static boolean equals(double x, double y) { return x == y;}
    static boolean equals(Object x, Object y) { return Objects.equals(x, y); }
}
public class Box<any X> {
    private final X x;
    public Box(X x) { this.x = x;}
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Box<X> box = (Box<X>) o;
        return PSupport.equals(x, box.x);
    }
}
But it doesn't accept PSupport.equals(x, box.x);
Thx
Boaz
    
    
More information about the valhalla-dev
mailing list