Created
October 31, 2017 05:56
-
-
Save liviutudor/38fdae6056cc9365d4e58a458cde4b34 to your computer and use it in GitHub Desktop.
Groovy bean one with handcrafted comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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