Class ExpandoMetaClass
- java.lang.Object
- 
- groovy.lang.MetaClassImpl
- 
- groovy.lang.ExpandoMetaClass
 
 
- 
- All Implemented Interfaces:
- GroovyObject,- MetaClass,- MetaObjectProtocol,- MutableMetaClass
 
 public class ExpandoMetaClass extends MetaClassImpl implements GroovyObject ExpandoMetaClass is a MetaClass that behaves like an Expando, allowing the addition or replacement of methods, properties and constructors on the fly.Some examples of usage: // defines or replaces instance method: metaClass.myMethod = { args->} // defines a new instance method metaClass.myMethod<<{ args->} // creates multiple overloaded methods of the same name metaClass.myMethod<<{ String s->}<<{ Integer i->} // defines or replaces a static method with the 'static' qualifier metaClass.'static'.myMethod = { args->} // defines a new static method with the 'static' qualifier metaClass.'static'.myMethod<<{ args->} // defines a new constructor metaClass.constructor<<{ String arg->} // defines or replaces a constructor metaClass.constructor = { String arg->} // defines a new property with an initial value of "blah" metaClass.myProperty = "blah"ExpandoMetaClass also supports a DSL/builder like notation to combine multiple definitions together. So instead of this: Number.metaClass.multiply = { Amount amountYou can also now do this:->amount.times(delegate) } Number.metaClass.div = { Amount amount->amount.inverse().times(delegate) }Number.metaClass { multiply { Amount amount->amount.times(delegate) } div { Amount amount->amount.inverse().times(delegate) } }ExpandoMetaClass also supports runtime mixins. While @Mixinallows you to mix in new behavior to classes you own and are designing, you can not easily mixin anything to types you didn't own, e.g. from third party libraries or from JDK library classes. Runtime mixins let you add a mixin on any type at runtime.interface Vehicle { String getName() } // Category annotation styleAs another example, consider the following class definitions:@Category(Vehicle) class FlyingAbility { def fly() { "I'm the ${name} and I fly!" } } // traditional category style class DivingAbility { static dive(Vehicle self) { "I'm the ${self.name} and I dive!" } } // provided by a third-party, so can't augment using Mixin annotation class JamesBondVehicle implements Vehicle { String getName() { "James Bond's vehicle" } } // Can be added via metaClass, e.g.: // JamesBondVehicle.metaClass.mixin DivingAbility, FlyingAbility // Or using shorthand through DGM method on Class JamesBondVehicle.mixin DivingAbility, FlyingAbility assert new JamesBondVehicle().fly() == "I'm the James Bond's vehicle and I fly!" assert new JamesBondVehicle().dive() == "I'm the James Bond's vehicle and I dive!"class Student { ListWe can mimic a form of multiple inheritance as follows:schedule = [] def addLecture(String lecture) { schedule <<lecture } } class Worker { Listschedule = [] def addMeeting(String meeting) { schedule <<meeting } }class CollegeStudent { static { mixin Student, Worker } } new CollegeStudent().with { addMeeting('Performance review with Boss') addLecture('Learn about Groovy Mixins') println schedule println mixedIn[Student].schedule println mixedIn[Worker].schedule }Which outputs these lines when run:[Performance review with Boss] [Learn about Groovy Mixins] [Performance review with Boss] Perhaps some explanation is required here. The methods and properties of Student and Worker are added to CollegeStudent. Worker is added last, so for overlapping methods, its methods will be used, e.g. when callingschedule, it will be the schedule property (getSchedule method) from Worker that is used. The schedule property from Student will be shadowed but themixedInnotation allows us to get to that too if we need as the last two lines show.We can also be a little more dynamic and not require the CollegeStudent class to be defined at all, e.g.: def cs = new Object() cs.metaClass { mixin Student, Worker getSchedule { mixedIn[Student].schedule + mixedIn[Worker].schedule } } cs.with { addMeeting('Performance review with Boss') addLecture('Learn about Groovy Mixins') println schedule }Which outputs this line when run:[Learn about Groovy Mixins, Performance review with Boss] As another example, we can also define a no dup queue by mixing in some Queue and Set functionality as follows:def ndq = new Object() ndq.metaClass { mixin ArrayDeque mixin HashSet leftShift = { Object oAs a final example, we sometimes need to pass such mixed in classes or objects into Java methods which require a given static type but the ExpandoMetaClass mixin approach uses a very dynamic approach based on duck typing rather than static interface definitions, so doesn't by default produce objects matching the required static type. Luckily, there is a mixins capability within ExpandoMetaClass which supports the use of Groovy's common 'as StaticType' notation to produce an object having the correct static type so that it can be passed to the Java method call in question. A slightly contrived example illustrating this feature:->if (!mixedIn[Set].contains(o)) { mixedIn[Queue].push(o) mixedIn[Set].add(o) } } } ndq<<1 ndq<<2 ndq<<1 assert ndq.size() == 2class CustomComparator implements Comparator { int compare(Object a, b) { return a.size() - b.size() } } class CustomCloseable implements Closeable { void close() { println 'Lights out - I am closing' } } import static mypackage.IOUtils.closeQuietly import static java.util.Collections.sort def o = new Object() o.metaClass.mixin CustomComparator, CustomCloseable def items = ['a', 'bbb', 'cc'] sort(items, o as Comparator) println items //=>[a, cc, bbb] closeQuietly(o as Closeable) //=>Lights out - I am closingFurther details When using the default implementations of MetaClass, methods are only allowed to be added before initialize() is called. In other words you create a new MetaClass, add some methods and then call initialize(). If you attempt to add new methods after initialize() has been called, an error will be thrown. This is to ensure that the MetaClass can operate appropriately in multi-threaded environments as it forces you to do all method additions at the beginning, before using the MetaClass. ExpandoMetaClass differs here from the default in that it allows you to add methods after initialize has been called. This is done by setting the initialize flag internally to false and then add the methods. Since this is not thread safe it has to be done in a synchronized block. The methods to check for modification and initialization are therefore synchronized as well. Any method call done through this meta class will first check if the it is synchronized. Should this happen during a modification, then the method cannot be selected or called unless the modification is completed. - Since:
- 1.5
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classExpandoMetaClass.ExpandoMetaConstructorHandles the ability to use the left shift operator to append new constructorsprotected classExpandoMetaClass.ExpandoMetaPropertyInstances of this class are returned when using the<<left shift operator.- 
Nested classes/interfaces inherited from class groovy.lang.MetaClassImplMetaClassImpl.Index, MetaClassImpl.MetaConstructor
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringCONSTRUCTORbooleaninRegistrystatic java.lang.StringSTATIC_QUALIFIER- 
Fields inherited from class groovy.lang.MetaClassImplEMPTY_ARGUMENTS, getPropertyMethod, INVOKE_METHOD_METHOD, invokeMethodMethod, isGroovyObject, isMap, metaMethodIndex, METHOD_MISSING, PROPERTY_MISSING, registry, setPropertyMethod, STATIC_METHOD_MISSING, STATIC_PROPERTY_MISSING, theCachedClass, theClass
 
- 
 - 
Constructor SummaryConstructors Constructor Description ExpandoMetaClass(MetaClassRegistry registry, java.lang.Class theClass, boolean register, boolean allowChangesAfterInit, MetaMethod[] add)ExpandoMetaClass(java.lang.Class theClass)Constructs a new ExpandoMetaClass instance for the given classExpandoMetaClass(java.lang.Class theClass, boolean register)Constructs a new ExpandoMetaClass instance for the given class optionally placing the MetaClass in the MetaClassRegistry automaticallyExpandoMetaClass(java.lang.Class theClass, boolean register, boolean allowChangesAfterInit)Constructs a new ExpandoMetaClass instance for the given class optionally placing the MetaClass in the MetaClassRegistry automaticallyExpandoMetaClass(java.lang.Class theClass, boolean register, boolean allowChangesAfterInit, MetaMethod[] add)ExpandoMetaClass(java.lang.Class theClass, boolean register, MetaMethod[] add)ExpandoMetaClass(java.lang.Class theClass, MetaMethod[] add)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMixinClass(MixinInMetaClass mixin)java.lang.ObjectcastToMixedType(java.lang.Object obj, java.lang.Class type)protected voidcheckInitalised()checks if the initialisation of the class id complete.CallSitecreateConstructorSite(CallSite site, java.lang.Object[] args)Create a CallSiteCallSitecreatePogoCallCurrentSite(CallSite site, java.lang.Class sender, java.lang.String name, java.lang.Object[] args)CallSitecreatePogoCallSite(CallSite site, java.lang.Object[] args)Create a CallSiteCallSitecreatePojoCallSite(CallSite site, java.lang.Object receiver, java.lang.Object[] args)Create a CallSiteCallSitecreateStaticSite(CallSite site, java.lang.Object[] args)Create a CallSiteExpandoMetaClassdefine(Closure closure)static voiddisableGlobally()Call to disable the global use of ExpandoMetaClassstatic voidenableGlobally()Call to enable global use of ExpandoMetaClass within the registry.MetaMethodfindMixinMethod(java.lang.String methodName, java.lang.Class[] arguments)java.util.List<MetaMethod>getExpandoMethods()Returns a list of expando MetaMethod instances added to this ExpandoMetaClassjava.util.Collection<MetaProperty>getExpandoProperties()Returns a list of MetaBeanProperty instances added to this ExpandoMetaClassjava.util.CollectiongetExpandoSubclassMethods()java.lang.ClassgetJavaClass()MetaClassgetMetaClass()Returns the metaclass for a given class.MetaPropertygetMetaProperty(java.lang.String name)Looks up an existing MetaProperty by namejava.util.List<MetaMethod>getMethods()Overrides the behavior of parent getMethods() method to make MetaClass aware of added Expando methodsjava.util.List<MetaProperty>getProperties()Get all the properties defined for this typejava.lang.ObjectgetProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, boolean useSuper, boolean fromInsideClass)Overrides default implementation just in case getProperty method has been overridden by ExpandoMetaClassjava.lang.ObjectgetProperty(java.lang.Object object, java.lang.String name)Overrides default implementation just in case getProperty method has been overridden by ExpandoMetaClassjava.lang.ObjectgetProperty(java.lang.String property)Retrieves a property value.java.lang.StringgetPropertyForSetter(java.lang.String setterName)Returns a property name equivalent for the given setter name or null if it is not a getterprotected java.lang.ObjectgetSubclassMetaMethods(java.lang.String methodName)booleanhasCustomStaticInvokeMethod()indicates is the meta class method invocation for static methods is done through a custom invoker object.booleanhasMetaMethod(java.lang.String name, java.lang.Class[] args)Checks whether a MetaMethod for the given name and arguments existsbooleanhasMetaProperty(java.lang.String name)Returns true if the MetaClass has the given propertyvoidinitialize()Complete the initialisation process.java.lang.ObjectinvokeConstructor(java.lang.Object[] arguments)Invokes a constructor for the given arguments.java.lang.ObjectinvokeMethod(java.lang.Class sender, java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass)Overrides default implementation just in case invokeMethod has been overridden by ExpandoMetaClassjava.lang.ObjectinvokeMethod(java.lang.String name, java.lang.Object args)Invokes the given method.java.lang.ObjectinvokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)Overrides default implementation just in case a static invoke method has been set on ExpandoMetaClassprotected booleanisInitialized()Checks if the meta class is initialized.booleanisModified()Returns whether this MetaClassImpl has been modified.booleanisSetter(java.lang.String name, CachedClass[] args)static booleanisValidExpandoProperty(java.lang.String property)protected voidonGetPropertyFoundInHierarchy(MetaMethod method)protected voidonInvokeMethodFoundInHierarchy(MetaMethod method)protected voidonSetPropertyFoundInHierarchy(MetaMethod method)protected voidonSuperMethodFoundInHierarchy(MetaMethod method)protected voidonSuperPropertyFoundInHierarchy(MetaBeanProperty property)protected voidperformOperationOnMetaClass(groovy.lang.ExpandoMetaClass.Callable c)voidrefreshInheritedMethods(java.util.Set modifiedSuperExpandos)Called from ExpandoMetaClassCreationHandle in the registry if it exists to set up inheritance handlingvoidregisterBeanProperty(java.lang.String property, java.lang.Object newValue)Registers a new bean propertyvoidregisterInstanceMethod(MetaMethod metaMethod)Registers a new instance method for the given method name and closure on this MetaClassvoidregisterInstanceMethod(java.lang.String name, Closure closure)protected voidregisterStaticMethod(java.lang.String name, Closure callable)protected voidregisterStaticMethod(java.lang.String name, Closure callable, java.lang.Class[] paramTypes)Registers a new static method for the given method name and closure on this MetaClassvoidregisterSubclassInstanceMethod(MetaMethod metaMethod)voidregisterSubclassInstanceMethod(java.lang.String name, java.lang.Class klazz, Closure closure)MetaMethodretrieveConstructor(java.lang.Object[] args)This is a helper method added in Groovy 2.1.0, which is used only by indy.protected voidsetInitialized(boolean b)voidsetMetaClass(MetaClass metaClass)Allows the MetaClass to be replaced with a derived implementation.voidsetProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)Overrides default implementation just in case setProperty method has been overridden by ExpandoMetaClassvoidsetProperty(java.lang.String property, java.lang.Object newValue)Sets the given property to the new value.- 
Methods inherited from class groovy.lang.MetaClassImpladdMetaBeanProperty, addMetaMethod, addMetaMethodToIndex, addNewInstanceMethod, addNewStaticMethod, applyPropertyDescriptors, checkIfGroovyObjectMethod, chooseMethod, clearInvocationCaches, createErrorMessageForAmbiguity, createPogoCallCurrentSite, createTransformMetaMethod, doChooseMostSpecificParams, dropMethodCache, dropStaticMethodCache, findMethodInClassHierarchy, findOwnMethod, findPropertyInClassHierarchy, getAdditionalMetaMethods, getAttribute, getAttribute, getAttribute, getClassInfo, getClassNode, getEffectiveGetMetaProperty, getMetaMethod, getMetaMethods, getMethodWithCaching, getMethodWithoutCaching, getRegistry, getStaticMetaMethod, getSuperClasses, getTheCachedClass, getTheClass, getVersion, handleMatches, hasCustomInvokeMethod, hasProperty, incVersion, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, onMixinMethodFound, pickMethod, respondsTo, respondsTo, retrieveConstructor, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setAttribute, setProperties, setProperty, toString
 
- 
 
- 
- 
- 
Field Detail- 
STATIC_QUALIFIERpublic static final java.lang.String STATIC_QUALIFIER - See Also:
- Constant Field Values
 
 - 
CONSTRUCTORpublic static final java.lang.String CONSTRUCTOR - See Also:
- Constant Field Values
 
 - 
inRegistrypublic boolean inRegistry 
 
- 
 - 
Constructor Detail- 
ExpandoMetaClasspublic ExpandoMetaClass(java.lang.Class theClass, boolean register, boolean allowChangesAfterInit, MetaMethod[] add)
 - 
ExpandoMetaClasspublic ExpandoMetaClass(MetaClassRegistry registry, java.lang.Class theClass, boolean register, boolean allowChangesAfterInit, MetaMethod[] add) 
 - 
ExpandoMetaClasspublic ExpandoMetaClass(java.lang.Class theClass) Constructs a new ExpandoMetaClass instance for the given class- Parameters:
- theClass- The class that the MetaClass applies to
 
 - 
ExpandoMetaClasspublic ExpandoMetaClass(java.lang.Class theClass, MetaMethod[] add)
 - 
ExpandoMetaClasspublic ExpandoMetaClass(java.lang.Class theClass, boolean register)Constructs a new ExpandoMetaClass instance for the given class optionally placing the MetaClass in the MetaClassRegistry automatically- Parameters:
- theClass- The class that the MetaClass applies to
- register- True if the MetaClass should be registered inside the MetaClassRegistry. This defaults to true and ExpandoMetaClass will effect all instances if changed
 
 - 
ExpandoMetaClasspublic ExpandoMetaClass(java.lang.Class theClass, boolean register, MetaMethod[] add)
 - 
ExpandoMetaClasspublic ExpandoMetaClass(java.lang.Class theClass, boolean register, boolean allowChangesAfterInit)Constructs a new ExpandoMetaClass instance for the given class optionally placing the MetaClass in the MetaClassRegistry automatically- Parameters:
- theClass- The class that the MetaClass applies to
- register- True if the MetaClass should be registered inside the MetaClassRegistry. This defaults to true and ExpandoMetaClass will effect all instances if changed
- allowChangesAfterInit- Should the meta class be modifiable after initialization. Default is false.
 
 
- 
 - 
Method Detail- 
getExpandoSubclassMethodspublic java.util.Collection getExpandoSubclassMethods() 
 - 
findMixinMethodpublic MetaMethod findMixinMethod(java.lang.String methodName, java.lang.Class[] arguments) - Overrides:
- findMixinMethodin class- MetaClassImpl
 
 - 
onInvokeMethodFoundInHierarchyprotected void onInvokeMethodFoundInHierarchy(MetaMethod method) - Overrides:
- onInvokeMethodFoundInHierarchyin class- MetaClassImpl
 
 - 
onSuperMethodFoundInHierarchyprotected void onSuperMethodFoundInHierarchy(MetaMethod method) - Overrides:
- onSuperMethodFoundInHierarchyin class- MetaClassImpl
 
 - 
onSuperPropertyFoundInHierarchyprotected void onSuperPropertyFoundInHierarchy(MetaBeanProperty property) - Overrides:
- onSuperPropertyFoundInHierarchyin class- MetaClassImpl
 
 - 
onSetPropertyFoundInHierarchyprotected void onSetPropertyFoundInHierarchy(MetaMethod method) - Overrides:
- onSetPropertyFoundInHierarchyin class- MetaClassImpl
 
 - 
onGetPropertyFoundInHierarchyprotected void onGetPropertyFoundInHierarchy(MetaMethod method) - Overrides:
- onGetPropertyFoundInHierarchyin class- MetaClassImpl
 
 - 
isModifiedpublic boolean isModified() Description copied from class:MetaClassImplReturns whether this MetaClassImpl has been modified. Since MetaClassImpl is not designed for modification this method always returns false- Specified by:
- isModifiedin interface- MutableMetaClass
- Overrides:
- isModifiedin class- MetaClassImpl
- Returns:
- false
 
 - 
registerSubclassInstanceMethodpublic void registerSubclassInstanceMethod(java.lang.String name, java.lang.Class klazz, Closure closure)
 - 
registerSubclassInstanceMethodpublic void registerSubclassInstanceMethod(MetaMethod metaMethod) 
 - 
addMixinClasspublic void addMixinClass(MixinInMetaClass mixin) 
 - 
castToMixedTypepublic java.lang.Object castToMixedType(java.lang.Object obj, java.lang.Class type)
 - 
enableGloballypublic static void enableGlobally() Call to enable global use of ExpandoMetaClass within the registry. This has the advantage that inheritance will function correctly and metaclass modifications will also apply to existing objects, but has a higher memory usage on the JVM than normal Groovy
 - 
disableGloballypublic static void disableGlobally() Call to disable the global use of ExpandoMetaClass
 - 
initializepublic void initialize() Complete the initialisation process. After this method is called no methods should be added to the meta class. Invocation of methods or access to fields/properties is forbidden unless this method is called. This method should contain any initialisation code, taking a longer time to complete. An example is the creation of the Reflector. It is suggested to synchronize this method.- Specified by:
- initializein interface- MetaClass
- Overrides:
- initializein class- MetaClassImpl
 
 - 
isInitializedprotected boolean isInitialized() Checks if the meta class is initialized.- Overrides:
- isInitializedin class- MetaClassImpl
- See Also:
- MetaClassImpl.isInitialized()
 
 - 
setInitializedprotected void setInitialized(boolean b) - Overrides:
- setInitializedin class- MetaClassImpl
 
 - 
invokeConstructorpublic java.lang.Object invokeConstructor(java.lang.Object[] arguments) Description copied from interface:MetaObjectProtocolInvokes a constructor for the given arguments. The MetaClass will attempt to pick the best argument which matches the types of the objects passed within the arguments array- Specified by:
- invokeConstructorin interface- MetaObjectProtocol
- Overrides:
- invokeConstructorin class- MetaClassImpl
- Parameters:
- arguments- The arguments to the constructor
- Returns:
- An instance of the java.lang.Class that this MetaObjectProtocol object applies to
 
 - 
getMetaClasspublic MetaClass getMetaClass() Description copied from interface:GroovyObjectReturns the metaclass for a given class.- Specified by:
- getMetaClassin interface- GroovyObject
- Returns:
- the metaClass of this instance
 
 - 
getPropertypublic java.lang.Object getProperty(java.lang.String property) Description copied from interface:GroovyObjectRetrieves a property value.- Specified by:
- getPropertyin interface- GroovyObject
- Parameters:
- property- the name of the property of interest
- Returns:
- the given property
 
 - 
isValidExpandoPropertypublic static boolean isValidExpandoProperty(java.lang.String property) 
 - 
invokeMethodpublic java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)Description copied from interface:GroovyObjectInvokes the given method.- Specified by:
- invokeMethodin interface- GroovyObject
- Parameters:
- name- the name of the method to call
- args- the arguments to use for the method call
- Returns:
- the result of invoking the method
 
 - 
setMetaClasspublic void setMetaClass(MetaClass metaClass) Description copied from interface:GroovyObjectAllows the MetaClass to be replaced with a derived implementation.- Specified by:
- setMetaClassin interface- GroovyObject
- Parameters:
- metaClass- the new metaclass
 
 - 
setPropertypublic void setProperty(java.lang.String property, java.lang.Object newValue)Description copied from interface:GroovyObjectSets the given property to the new value.- Specified by:
- setPropertyin interface- GroovyObject
- Parameters:
- property- the name of the property of interest
- newValue- the new value for the property
 
 - 
definepublic ExpandoMetaClass define(@DelegatesTo(value=groovy.lang.ExpandoMetaClass.DefiningClosure.class,strategy=3) Closure closure) 
 - 
performOperationOnMetaClassprotected void performOperationOnMetaClass(groovy.lang.ExpandoMetaClass.Callable c) 
 - 
checkInitalisedprotected void checkInitalised() Description copied from class:MetaClassImplchecks if the initialisation of the class id complete. This method should be called as a form of assert, it is no way to test if there is still initialisation work to be done. Such logic must be implemented in a different way.- Overrides:
- checkInitalisedin class- MetaClassImpl
 
 - 
registerBeanPropertypublic void registerBeanProperty(java.lang.String property, java.lang.Object newValue)Registers a new bean property- Parameters:
- property- The property name
- newValue- The properties initial value
 
 - 
registerInstanceMethodpublic void registerInstanceMethod(MetaMethod metaMethod) Registers a new instance method for the given method name and closure on this MetaClass- Parameters:
- metaMethod-
 
 - 
registerInstanceMethodpublic void registerInstanceMethod(java.lang.String name, Closure closure)
 - 
getMethodspublic java.util.List<MetaMethod> getMethods() Overrides the behavior of parent getMethods() method to make MetaClass aware of added Expando methods- Specified by:
- getMethodsin interface- MetaClass
- Specified by:
- getMethodsin interface- MetaObjectProtocol
- Overrides:
- getMethodsin class- MetaClassImpl
- Returns:
- A list of MetaMethods
- See Also:
- MetaObjectProtocol.getMethods()
 
 - 
getPropertiespublic java.util.List<MetaProperty> getProperties() Description copied from class:MetaClassImplGet all the properties defined for this type- Specified by:
- getPropertiesin interface- MetaClass
- Specified by:
- getPropertiesin interface- MetaObjectProtocol
- Overrides:
- getPropertiesin class- MetaClassImpl
- Returns:
- a list of MetaProperty objects
- See Also:
- MetaProperty
 
 - 
registerStaticMethodprotected void registerStaticMethod(java.lang.String name, Closure callable)
 - 
registerStaticMethodprotected void registerStaticMethod(java.lang.String name, Closure callable, java.lang.Class[] paramTypes)Registers a new static method for the given method name and closure on this MetaClass- Parameters:
- name- The method name
- callable- The callable Closure
 
 - 
getSubclassMetaMethodsprotected java.lang.Object getSubclassMetaMethods(java.lang.String methodName) - Overrides:
- getSubclassMetaMethodsin class- MetaClassImpl
 
 - 
getJavaClasspublic java.lang.Class getJavaClass() - Returns:
- The Java class enhanced by this MetaClass
 
 - 
refreshInheritedMethodspublic void refreshInheritedMethods(java.util.Set modifiedSuperExpandos) Called from ExpandoMetaClassCreationHandle in the registry if it exists to set up inheritance handling- Parameters:
- modifiedSuperExpandos- A list of modified super ExpandoMetaClass
 
 - 
getExpandoMethodspublic java.util.List<MetaMethod> getExpandoMethods() Returns a list of expando MetaMethod instances added to this ExpandoMetaClass- Returns:
- the expandoMethods
 
 - 
getExpandoPropertiespublic java.util.Collection<MetaProperty> getExpandoProperties() Returns a list of MetaBeanProperty instances added to this ExpandoMetaClass- Returns:
- the expandoProperties
 
 - 
invokeMethodpublic java.lang.Object invokeMethod(java.lang.Class sender, java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass)Overrides default implementation just in case invokeMethod has been overridden by ExpandoMetaClass- Specified by:
- invokeMethodin interface- MetaClass
- Overrides:
- invokeMethodin class- MetaClassImpl
- Parameters:
- sender- The java.lang.Class instance that invoked the method
- object- The object which the method was invoked on
- methodName- The name of the method
- originalArguments- The arguments to the method
- isCallToSuper- Whether the method is a call to a super class method
- fromInsideClass- Whether the call was invoked from the inside or the outside of the class
- Returns:
- The return value of the method
- See Also:
- MetaClassImpl.invokeMethod(Class, Object, String, Object[], boolean, boolean)
 
 - 
invokeStaticMethodpublic java.lang.Object invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)Overrides default implementation just in case a static invoke method has been set on ExpandoMetaClass- Specified by:
- invokeStaticMethodin interface- MetaObjectProtocol
- Overrides:
- invokeStaticMethodin class- MetaClassImpl
- Parameters:
- object- An instance of the class returned by the getTheClass() method or the class itself
- methodName- The name of the method
- arguments- The arguments to the method
- Returns:
- The return value of the method which is null if the return type is void
- See Also:
- MetaClassImpl.invokeStaticMethod(Object, String, Object[])
 
 - 
getPropertypublic java.lang.Object getProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, boolean useSuper, boolean fromInsideClass)Overrides default implementation just in case getProperty method has been overridden by ExpandoMetaClass- Specified by:
- getPropertyin interface- MetaClass
- Overrides:
- getPropertyin class- MetaClassImpl
- Parameters:
- sender- The java.lang.Class instance that requested the property
- object- The Object which the property is being retrieved from
- name- The name of the property
- useSuper- Whether the call is to a super class property
- fromInsideClass- ??
- Returns:
- the given property's value on the object
- See Also:
- MetaClassImpl.getProperty(Class, Object, String, boolean, boolean)
 
 - 
getPropertypublic java.lang.Object getProperty(java.lang.Object object, java.lang.String name)Overrides default implementation just in case getProperty method has been overridden by ExpandoMetaClass- Specified by:
- getPropertyin interface- MetaObjectProtocol
- Overrides:
- getPropertyin class- MetaClassImpl
- Parameters:
- object- The Object which the property is being retrieved from
- name- The name of the property
- Returns:
- The properties value
- See Also:
- MetaClassImpl.getProperty(Object, String)
 
 - 
setPropertypublic void setProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)Overrides default implementation just in case setProperty method has been overridden by ExpandoMetaClass- Specified by:
- setPropertyin interface- MetaClass
- Overrides:
- setPropertyin class- MetaClassImpl
- Parameters:
- sender- The java.lang.Class instance that is mutating the property
- object- The Object which the property is being set on
- name- The name of the property
- newValue- The new value of the property to set
- useSuper- Whether the call is to a super class property
- fromInsideClass- Whether the call was invoked from the inside or the outside of the class.
- See Also:
- MetaClassImpl.setProperty(Class, Object, String, Object, boolean, boolean)
 
 - 
getMetaPropertypublic MetaProperty getMetaProperty(java.lang.String name) Looks up an existing MetaProperty by name- Specified by:
- getMetaPropertyin interface- MetaObjectProtocol
- Overrides:
- getMetaPropertyin class- MetaClassImpl
- Parameters:
- name- The name of the MetaProperty
- Returns:
- The MetaProperty or null if it doesn't exist
- See Also:
- MetaObjectProtocol.getMetaProperty(String)
 
 - 
hasMetaPropertypublic boolean hasMetaProperty(java.lang.String name) Returns true if the MetaClass has the given property- Parameters:
- name- The name of the MetaProperty
- Returns:
- True it exists as a MetaProperty
 
 - 
hasMetaMethodpublic boolean hasMetaMethod(java.lang.String name, java.lang.Class[] args)Checks whether a MetaMethod for the given name and arguments exists- Parameters:
- name- The name of the MetaMethod
- args- The arguments to the meta method
- Returns:
- True if the method exists otherwise null
 
 - 
getPropertyForSetterpublic java.lang.String getPropertyForSetter(java.lang.String setterName) Returns a property name equivalent for the given setter name or null if it is not a getter- Parameters:
- setterName- The setter name
- Returns:
- The property name equivalent
 
 - 
isSetterpublic boolean isSetter(java.lang.String name, CachedClass[] args)
 - 
createPojoCallSitepublic CallSite createPojoCallSite(CallSite site, java.lang.Object receiver, java.lang.Object[] args) Description copied from class:MetaClassImplCreate a CallSite- Overrides:
- createPojoCallSitein class- MetaClassImpl
 
 - 
createStaticSitepublic CallSite createStaticSite(CallSite site, java.lang.Object[] args) Description copied from class:MetaClassImplCreate a CallSite- Overrides:
- createStaticSitein class- MetaClassImpl
 
 - 
hasCustomStaticInvokeMethodpublic boolean hasCustomStaticInvokeMethod() Description copied from class:MetaClassImplindicates is the meta class method invocation for static methods is done through a custom invoker object.- Overrides:
- hasCustomStaticInvokeMethodin class- MetaClassImpl
- Returns:
- true - if the method invocation is not done by the meta class itself
 
 - 
createPogoCallSitepublic CallSite createPogoCallSite(CallSite site, java.lang.Object[] args) Description copied from class:MetaClassImplCreate a CallSite- Overrides:
- createPogoCallSitein class- MetaClassImpl
 
 - 
createPogoCallCurrentSitepublic CallSite createPogoCallCurrentSite(CallSite site, java.lang.Class sender, java.lang.String name, java.lang.Object[] args) 
 - 
retrieveConstructorpublic MetaMethod retrieveConstructor(java.lang.Object[] args) Description copied from class:MetaClassImplThis is a helper method added in Groovy 2.1.0, which is used only by indy. This method is for internal use only.- Overrides:
- retrieveConstructorin class- MetaClassImpl
 
 - 
createConstructorSitepublic CallSite createConstructorSite(CallSite site, java.lang.Object[] args) Description copied from class:MetaClassImplCreate a CallSite- Overrides:
- createConstructorSitein class- MetaClassImpl
 
 
- 
 
-