Package org.codehaus.groovy.reflection
Class MixinInMetaClass
java.lang.Object
org.codehaus.groovy.reflection.MixinInMetaClass
Manages the integration of mixin classes into expandable metaclasses.
Associates a mixin class with instances of an expandable metaclass, enabling per-instance mixin functionality. Handles mixin instance creation and registration of mixin methods/properties.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks equality with another object based on the expandable metaclass and mixin class.Returns the cached class for the expandable metaclass that owns this mixin.Returns the cached class of the mixin class itself.getMixinInstance(Object object) Returns or creates a mixin instance for the given object.inthashCode()Returns the hash code based on the mixin class.static voidmixinClassesToMetaClass(MetaClass self, List<Class> categoryClasses) Integrates mixin classes into the specified metaclass.voidsetMixinInstance(Object object, Object mixinInstance) Sets or clears the mixin instance associated with an object.
-
Method Details
-
getMixinInstance
Returns or creates a mixin instance for the given object. Creates a new mixin instance on first access, then caches and reuses it for the same object.- Parameters:
object- the object to associate with a mixin instance- Returns:
- the mixin instance for this object
-
setMixinInstance
Sets or clears the mixin instance associated with an object. Passnullto remove the mixin association.- Parameters:
object- the object to associate or disassociate with a mixinmixinInstance- the mixin instance to associate, ornullto clear
-
getInstanceClass
Returns the cached class for the expandable metaclass that owns this mixin.- Returns:
- the cached class for the instance
-
getMixinClass
Returns the cached class of the mixin class itself.- Returns:
- the cached mixin class
-
mixinClassesToMetaClass
Integrates mixin classes into the specified metaclass. Each mixin class provides methods that are mixed into the target class.- Parameters:
self- the metaclass to mix methods intocategoryClasses- the classes providing mixin methods
-
equals
Checks equality with another object based on the expandable metaclass and mixin class. -
hashCode
public int hashCode()Returns the hash code based on the mixin class.
-