Created
January 15, 2015 05:57
-
-
Save sbrady/277dd678509061e35bf5 to your computer and use it in GitHub Desktop.
Example decorator pattern in Groovy using @DeleGate
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
class Person { | |
String firstName | |
String lastName | |
} | |
class PersonDecorator { | |
private @Delegate Person person | |
def fullName() { | |
"$firstName $lastName" | |
} | |
} | |
def person = new Person(firstName: "Sean", lastName: "Brady") | |
def personDecorator = new PersonDecorator(person: person) | |
println personDecorator.fullName() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment