Enum Class CtImportKind

java.lang.Object
java.lang.Enum<CtImportKind>
spoon.reflect.declaration.CtImportKind
All Implemented Interfaces:
Serializable, Comparable<CtImportKind>, Constable

public enum CtImportKind extends Enum<CtImportKind>
Enumeration of the different kinds of Java imports that can appear in a compilation unit.

This enum represents both traditional package imports (from Java source files) and module imports

  • Enum Constant Details

    • TYPE

      public static final CtImportKind TYPE
      A single type import declaration.

      Example: import my.package.Type;

      This allows referencing the type by its simple name instead of its fully-qualified name.

    • ALL_TYPES

      public static final CtImportKind ALL_TYPES
      An on-demand import declaration for all types in a package.

      Example: import my.package.*;

      This makes all public types in the specified package available using their simple names.

    • ALL_STATIC_MEMBERS

      public static final CtImportKind ALL_STATIC_MEMBERS
      A static on-demand import declaration for all static members of a type.

      Example: import static my.package.Type.*;

      This makes all static members (fields, methods, and nested types) of the specified type available without qualifying them with the type name.

    • FIELD

      public static final CtImportKind FIELD
      A static import declaration for a single static field.

      Example: import static my.package.Type.f;

      This allows referencing the static field by its simple name within the importing compilation unit.

    • METHOD

      public static final CtImportKind METHOD
      A static import declaration for all static methods with this name.

      Example: import static my.package.Type.m;

      This allows calling a static method by its simple name within the importing compilation unit.

    • UNRESOLVED

      public static final CtImportKind UNRESOLVED
      An import that cannot be resolved to a specific kind.

      This kind is used when Spoon operates in no-classpath mode and the reference cannot be resolved. In such cases, the import is stored as a plain string and printed as-is during pretty printing. The original import statement is preserved without semantic analysis.

    • MODULE

      public static final CtImportKind MODULE
      A module import declaration for all public types of a Java module.

      Example: import module java.base;

  • Method Details

    • values

      public static CtImportKind[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CtImportKind valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null