Package org.codehaus.groovy.transform

# Class StubberSupport

java.lang.Object
org.codehaus.groovy.transform.StubberSupport

public final class StubberSupport extends Object
Utilities for GEP-21 Shape C joint-compilation stubbers.

A stubber emits placeholder members at `Phases.CONVERSION` so the joint-compilation stub reflects what the full transform will produce at its declared phase. The placeholder is tagged with `STUB_METADATA_KEY`; the full transform recognises the tag and either replaces the placeholder body or discards the placeholder before adding its own member.

All stubbers share a single metadata key — the runtime mapping between a placeholder and the full transform that should complete it is given by the member's signature, not by per-stubber namespacing.

Since:
  6.0.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `STUB_METADATA_KEY`
  Metadata key tagging a member that was added by a CONVERSION-phase stubber as a placeholder.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ConstructorNode`
  `addStubConstructor(ClassNode classNode, int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement body)`
  Add a placeholder constructor via `ClassNodeUtils.addGeneratedConstructor(ClassNode, int, Parameter[], ClassNode[], Statement)` and tag it with `STUB_METADATA_KEY`.
  `static MethodNode`
  `addStubMethod(ClassNode classNode, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement body)`
  Add a placeholder method via `ClassNodeUtils.addGeneratedMethod(org.codehaus.groovy.ast.ClassNode, java.lang.String, int, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.Parameter[], org.codehaus.groovy.ast.ClassNode[], org.codehaus.groovy.ast.stmt.Statement)` and tag it with `STUB_METADATA_KEY`.
  `static void`
  `clearStub(AnnotatedNode node)`
  Removes the stubber-placeholder tag from `node`, if present.
  `static boolean`
  `isStub(AnnotatedNode node)`
  Returns true when `node` carries the stubber-placeholder tag.
  `static <T extends AnnotatedNode>
  T`
  `tagAsStub(T node)`
  Tag an existing node as a stubber placeholder.

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

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

- ## Field Details

  - ### STUB_METADATA_KEY

    public static final String STUB_METADATA_KEY
    Metadata key tagging a member that was added by a CONVERSION-phase stubber as a placeholder. The paired full transform consults this key to decide whether to replace the body or discard the placeholder.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### addStubMethod

    public static MethodNode addStubMethod(ClassNode classNode, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement body)
    Add a placeholder method via `ClassNodeUtils.addGeneratedMethod(org.codehaus.groovy.ast.ClassNode, java.lang.String, int, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.Parameter[], org.codehaus.groovy.ast.ClassNode[], org.codehaus.groovy.ast.stmt.Statement)` and tag it with `STUB_METADATA_KEY`.

  - ### addStubConstructor

    public static ConstructorNode addStubConstructor(ClassNode classNode, int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement body)
    Add a placeholder constructor via `ClassNodeUtils.addGeneratedConstructor(ClassNode, int, Parameter[], ClassNode[], Statement)` and tag it with `STUB_METADATA_KEY`.

  - ### tagAsStub

    public static <T extends AnnotatedNode> T tagAsStub(T node)
    Tag an existing node as a stubber placeholder. Useful when the addition itself goes through a shared helper (e.g. `addComparableSurface`) so the stubber receives the resulting node and only needs to tag it.

  - ### isStub

    public static boolean isStub(AnnotatedNode node)
    Returns true when `node` carries the stubber-placeholder tag.

  - ### clearStub

    public static void clearStub(AnnotatedNode node)
    Removes the stubber-placeholder tag from `node`, if present.