Package: org.codehaus.groovy.reflection

## [Java] Class MixinInMetaClass

- 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.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `equals(Object that)` Checks equality with another object based on the expandable metaclass and mixin class.
    `` | `public CachedClass` | `getInstanceClass()` Returns the cached class for the expandable metaclass that owns this mixin.
    `` | `public CachedClass` | `getMixinClass()` Returns the cached class of the mixin class itself.
    `` | `public Object` | `getMixinInstance(Object object)` Returns or creates a mixin instance for the given object.
    `` | `public int` | `hashCode()` Returns the hash code based on the mixin class.
    `` | `public static void` | `mixinClassesToMetaClass(MetaClass self, List<Class> categoryClasses)` Integrates mixin classes into the specified metaclass.
    `` | `public void` | `setMixinInstance(Object object, Object mixinInstance)` Sets or clears the mixin instance associated with an object.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public boolean equals(Object that)

      Checks equality with another object based on the expandable metaclass and mixin class.

      Parameters:
        `that` - the object to compare with
      Returns:
        `true` if this mixin represents the same metaclass and mixin; `false` otherwise

    - #### public CachedClass getInstanceClass()

      Returns the cached class for the expandable metaclass that owns this mixin.

      Returns:
        the cached class for the instance

    - #### public CachedClass getMixinClass()

      Returns the cached class of the mixin class itself.

      Returns:
        the cached mixin class

    - #### 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

    - #### public int hashCode()

      Returns the hash code based on the mixin class.

      `ExpandoMetaClass` dedupes mixins (GROOVY-11775) through a CopyOnWriteArraySet, which compares with equals alone, so this must stay consistent with it rather than being relied upon for that deduplication.

      Returns:
        the hash code

    - #### 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

    - #### 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