Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Bean two with handcrafted comparison
package delegation
import groovy.transform.TupleConstructor
@TupleConstructor
class BeanTwo implements Comparable<BeanTwo> {
int yob
public int getAge() {
new Date().year - yob
}
@Override
int compareTo(BeanTwo o) {
if (!o) return false
if (this.is(o)) return false
return age <=> o.age
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment