Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Groovy bean one with handcrafted comparison
package delegation
import groovy.transform.TupleConstructor
@TupleConstructor
class BeanOne implements Comparable<BeanOne> {
String firstName
String familyName
public String getFullName() {
return "$firstName $familyName"
}
@Override
int compareTo(BeanOne o) {
if (!o) return false
if (this.is(o)) return false
return fullName <=> o.fullName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment