Wednesday, 15 September 2010

groovy - Mixin empty interface -



groovy - Mixin empty interface -

is there way mixin empty interface groovy object of wrapped primitive type? tried is:

interface b{} = new boolean(false) b = a.metaclass.mixin(b.class) assert b instanceof b

the error "groovy.lang.groovyruntimeexception: no default constructor class b! can't mixed in."

this isn't direct reply question, if you're looking mark particular boolean instances, utilize marker property instead of interface? example:

boolean.metaclass.marked = false // found marker property mb = new boolean(false) mb.marked = true ub = new boolean(false) assert mb.marked assert ub.marked == false

groovy metaprogramming mixins

No comments:

Post a Comment