John Rose had some time ago written up whats required to have tuples on the JVM: http://blogs.sun.com/jrose/entry/tuples_in_the_vm
-Marco On 8 Feb., 14:12, "[email protected]" <[email protected]> wrote: > This is the first time I've felt the need to change the language. I > guess everybody else here wants other changes. I've got this class in > every project I've worked on for the last 2 years. Anybody has a > better one? > > public class Par<P extends Serializable, Q extends Serializable> > implements Serializable { > > static final long serialVersionUID = 9L; > > private P car; > private Q cdr; > > public Par(P car, Q cdr) { > this.car = car; > this.cdr = cdr; > } > > public P getCar() { > return car; > } > > public Q getCdr() { > return cdr; > } > > @Override > public boolean equals(Object obj) { > if (obj == null) { > return false; > } > if (getClass() != obj.getClass()) { > return false; > } > @SuppressWarnings("unchecked") > final Par<P, Q> other = (Par<P, Q>) obj; > if (this.car != other.car && (this.car == null || ! > this.car.equals(other.car))) { > return false; > } > if (this.cdr != other.cdr && (this.cdr == null || ! > this.cdr.equals(other.cdr))) { > return false; > } > return true; > } > > @Override > public int hashCode() { > int hash = 9; > hash += 97 * hash + (this.car != null ? this.car.hashCode() : > 0); > hash += 97 * hash + (this.cdr != null ? this.cdr.hashCode() : > 0); > return hash; > } > > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---
