Class MixinInMetaClass

java.lang.Object
org.codehaus.groovy.reflection.MixinInMetaClass

public class MixinInMetaClass extends Object
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 Details

    • getMixinInstance

      public Object getMixinInstance(Object object)
      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

      public void setMixinInstance(Object object, Object mixinInstance)
      Sets or clears the mixin instance associated with an object. Pass null to remove the mixin association.
      Parameters:
      object - the object to associate or disassociate with a mixin
      mixinInstance - the mixin instance to associate, or null to clear
    • getInstanceClass

      public CachedClass getInstanceClass()
      Returns the cached class for the expandable metaclass that owns this mixin.
      Returns:
      the cached class for the instance
    • getMixinClass

      public CachedClass getMixinClass()
      Returns the cached class of the mixin class itself.
      Returns:
      the cached mixin class
    • mixinClassesToMetaClass

      public static void mixinClassesToMetaClass(MetaClass self, List<Class> categoryClasses)
      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 into
      categoryClasses - the classes providing mixin methods
    • equals

      public boolean equals(Object that)
      Checks equality with another object based on the expandable metaclass and mixin class.
      Overrides:
      equals in class Object
      Parameters:
      that - the object to compare with
      Returns:
      true if this mixin represents the same metaclass and mixin; false otherwise
    • hashCode

      public int hashCode()
      Returns the hash code based on the mixin class.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code