Created
October 31, 2017 05:58
-
-
Save liviutudor/33826f2f1256d006f37c3d7153ea3a2c to your computer and use it in GitHub Desktop.
after handcrafting the comparison in the beans we are delegating to
This file contains 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.Sortable | |
class DelegationBean { | |
@Delegate | |
BeanOne person | |
@Delegate | |
BeanTwo dateOfBirth | |
static void main(String... args) { | |
DelegationBean one = new DelegationBean(person: new BeanOne("Liviu", "Tudor"), dateOfBirth: new BeanTwo(yob: 1975)) | |
DelegationBean two = new DelegationBean(person: new BeanOne("William", "Shakespeare"), dateOfBirth: new BeanTwo(yob: 1564)) | |
assert one instanceof Comparable | |
println one.fullName | |
println two.fullName | |
println(one < two) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment