Package: org.codehaus.groovy.runtime

## [Java] Class IntersectionCastSupport

- org.codehaus.groovy.runtime.IntersectionCastSupport

-     public final class IntersectionCastSupport
      extends Object

  Runtime support for intersection-type cast and `as` coercion (GROOVY-11998). Compiler-generated bytecode for `(A & B) value` and `value as (A & B)` routes through these helpers when the target is an intersection type and the source is not a native lambda or method reference (those cases are handled at compile time via `LambdaMetafactory.altMetafactory` markers).

  Since:
    6.0.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static Object` | `asType(Object source, Class<?>[] components)` Coercion: produce an object that satisfies every component.
    `` | `public static Object` | `castTo(Object source, Class<?>[] components)` Strict cast: every component must already be assignment-compatible with the source's runtime class.

  - ### Inherited Methods Summary

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

- - ### Method Detail

    - #### public static Object asType(Object source, Class<?>[] components)

      Coercion: produce an object that satisfies every component. For Closure and Map sources, a multi-interface proxy is built via ProxyGenerator. For other sources, falls back to castTo so the behaviour is at least as strict as a cast.

    - #### public static Object castTo(Object source, Class<?>[] components)

      Strict cast: every component must already be assignment-compatible with the source's runtime class. Throws GroovyCastException otherwise.