Skip to content

Instantly share code, notes, and snippets.

@jonatasemidio
Last active August 29, 2015 14:04
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 jonatasemidio/6e936c1f5cdd18b1c377 to your computer and use it in GitHub Desktop.
Save jonatasemidio/6e936c1f5cdd18b1c377 to your computer and use it in GitHub Desktop.
Bind properties in Services
import org.codehaus.groovy.runtime.InvokerHelper
class A { String nome; Integer idade }
class B { String nome; Integer idade }
class C { String nome; Integer idade }
A a = new A()
B b = new B(nome:'jose', idade: 10)
C c = new C(nome:'bira', idade: 99)
use(InvokerHelper) { a.setProperties(b.properties) }
println a.properties
InvokerHelper.setProperties(a, c.properties)
println a.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment