Package org.codehaus.groovy.reflection

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

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

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

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

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

    Overrides:
      `hashCode` in class `Object`
    Returns:
      the hash code