Package: org.codehaus.groovy.transform

## [Java] Class SealedASTTransformation

- org.codehaus.groovy.transform.SealedASTTransformation

-     @GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS)
      public class SealedASTTransformation
      extends AbstractASTTransformation

  Handles generation of code for the

  Sealed:
    annotation.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static String` | `SEALED_ALWAYS_ANNOTATE` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class AbstractASTTransformation` | `RETENTION_CLASSNODE, sourceUnit`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static List<ClassNode>` | `getDeclaredPermittedSubclasses(ClassNode cNode)` Returns the explicitly-declared permitted-subclass list for `cNode`, either from the populated `permittedSubclasses` field (after the transform has run) or from the `@Sealed` annotation's `permittedSubclasses` member.
    `` | `public static List<ClassNode>` | `getEffectivePermittedSubclasses(ClassNode cNode)` Returns the effective permitted-subclass list for `cNode`: the explicitly-declared list when present, otherwise the inferred list obtained by scanning the enclosing compilation unit for direct subtypes (mirroring `SealedCompletionASTTransformation`).
    `` | `public static boolean` | `sealedNative(AnnotatedNode node)` Reports true if native sealed class information should be written into the bytecode.
    `` | `public static boolean` | `sealedSkipAnnotation(AnnotatedNode node)` Reports true if the `Sealed` annotation should not be included in the bytecode for a sealed or emulated-sealed class.
    `` | `public static boolean` | `sealedSkipAnnotationFromSource(ClassNode cNode)` Reports whether the source for `cNode` uses `@SealedOptions(alwaysAnnotate=false)` — independent of compile-phase ordering, so callers earlier than `SEMANTIC_ANALYSIS` can use it.
    `` | `public void` | `visit(ASTNode[] nodes, SourceUnit source)`
    `` | `public static boolean` | `wouldBeNativeSealed(ClassNode cNode, String targetBytecode)` Reports whether `cNode` would receive native sealed bytecode for the given `targetBytecode` level.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AbstractASTTransformation` | `addError, checkIncludeExcludeUndefinedAware, checkIncludeExcludeUndefinedAware, checkNotInterface, checkPropertyList, checkPropertyList, checkPropertyList, copyAnnotatedNodeAnnotations, copyAnnotatedNodeAnnotations, deemedInternal, deemedInternalName, getAnnotationName, getMemberClassList, getMemberClassValue, getMemberClassValue, getMemberIntValue, getMemberStringList, getMemberStringValue, getMemberStringValue, getMemberValue, hasAnnotation, init, markAsInternal, memberHasValue, shouldSkip, shouldSkip, shouldSkip, shouldSkipOnDescriptorUndefinedAware, shouldSkipUndefinedAware, shouldSkipUndefinedAware, shouldSkipUndefinedAware, tokenize`

- - ### Field Detail

    - #### @Deprecated
      public static final String SEALED_ALWAYS_ANNOTATE

  - ### Method Detail

    - #### public static List<ClassNode> getDeclaredPermittedSubclasses(ClassNode cNode)

      Returns the explicitly-declared permitted-subclass list for `cNode`, either from the populated `permittedSubclasses` field (after the transform has run) or from the `@Sealed` annotation's `permittedSubclasses` member. An empty list means no explicit list is declared in source — inference happens later via `SealedCompletionASTTransformation`. Independent of compile-phase ordering, so callers earlier than `SEMANTIC_ANALYSIS` can use it.

    - #### public static List<ClassNode> getEffectivePermittedSubclasses(ClassNode cNode)

      Returns the effective permitted-subclass list for `cNode`: the explicitly-declared list when present, otherwise the inferred list obtained by scanning the enclosing compilation unit for direct subtypes (mirroring `SealedCompletionASTTransformation`). Phase independent, so callers earlier than `CANONICALIZATION` can use it.

    - #### public static boolean sealedNative(AnnotatedNode node)

      Reports true if native sealed class information should be written into the bytecode. Will only ever return true after the SealedASTTransformation visit method has completed.

      Returns:
        true for a native sealed class

    - #### public static boolean sealedSkipAnnotation(AnnotatedNode node)

      Reports true if the `Sealed` annotation should not be included in the bytecode for a sealed or emulated-sealed class. Will only ever return true after the `SealedASTTransformation` transform has been invoked.

      Returns:
        true if a `Sealed` annotation is not required for this node

    - #### public static boolean sealedSkipAnnotationFromSource(ClassNode cNode)

      Reports whether the source for `cNode` uses `@SealedOptions(alwaysAnnotate=false)` — independent of compile-phase ordering, so callers earlier than `SEMANTIC_ANALYSIS` can use it.

    - #### public void visit(ASTNode[] nodes, SourceUnit source)

    - #### public static boolean wouldBeNativeSealed(ClassNode cNode, String targetBytecode)

      Reports whether `cNode` would receive native sealed bytecode for the given `targetBytecode` level. Independent of compile-phase ordering, so callers earlier than `SEMANTIC_ANALYSIS` (e.g. the joint-compile stub generator) can use it.

      Parameters:
        `cNode` - the class being checked
        `targetBytecode` - the target bytecode level (see CompilerConfiguration.getTargetBytecode)