Skip to content

Instantly share code, notes, and snippets.

@liviutudor
Created October 31, 2017 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liviutudor/38fdae6056cc9365d4e58a458cde4b34 to your computer and use it in GitHub Desktop.
Save liviutudor/38fdae6056cc9365d4e58a458cde4b34 to your computer and use it in GitHub Desktop.
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