Created
July 26, 2013 06:26
-
-
Save danveloper/6086719 to your computer and use it in GitHub Desktop.
Custom MetaClass Creation Handler for Groovy
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 com.objectpartners.groovy.ext; | |
import groovy.lang.MetaClass; | |
import groovy.lang.MetaClassRegistry; | |
import org.codehaus.groovy.runtime.GeneratedClosure; | |
import org.codehaus.groovy.runtime.metaclass.ClosureMetaClass; | |
class CustomMetaClassCreationHandle extends MetaClassRegistry.MetaClassCreationHandle { | |
protected MetaClass createNormalMetaClass(Class theClass,MetaClassRegistry registry) { | |
if (GeneratedClosure.class.isAssignableFrom(theClass)) { | |
return new ClosureMetaClass(registry,theClass); | |
} else { | |
return new MixinResolvingMetaClass(registry, theClass); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment