Class EnumDef


public class EnumDef extends ClassDef
A definition for an num, containing methods, fields, the names of interfaces that are implemented, and enum value constructors
  • Constructor Details

    • EnumDef

      public EnumDef(String packageName, String name, int access, MethodDef[] methodDefs, ClassField[] fields, EnumInitializer[] initializers, String[] interfaces)
      Create a class definition
      Parameters:
      packageName - The package name of the class (may be null)
      name - The name of the class
      access - Any access flags for the class (can be a sum of values from the Access class)
      methodDefs - The methods defined for this class
      fields - The fields defined for this class
      initializers - The initializers for each enum value
      interfaces - The interfaces this class implements
    • EnumDef

      public EnumDef(String packageName, String name, int access, MethodDef[] methodDefs, ClassField[] fields, EnumInitializer[] initializers, String[] interfaces, String filename, int lineNumber)
      Create a class definition
      Parameters:
      packageName - The package name of the class (may be null)
      name - The name of the class
      access - Any access flags for the class (can be a sum of values from the Access class)
      methodDefs - The methods defined for this class
      fields - The fields defined for this class
      initializers - The initializers for each enum value
      interfaces - The interfaces this class implements
      filename - The source code filename this class was generated from
      lineNumber - The starting line number in the source code where this class is defined
    • EnumDef

      public EnumDef(String packageName, String name, int access, MethodDef[] methodDefs, ClassField[] fields, String[] names, String[] interfaces)
      Create a class definition
      Parameters:
      packageName - The package name of the class (may be null)
      name - The name of the class
      access - Any access flags for the class (can be a sum of values from the Access class)
      methodDefs - The methods defined for this class
      fields - The fields defined for this class
      names - The names of each enum value
      interfaces - The interfaces this class implements
    • EnumDef

      public EnumDef(String packageName, String name, int access, MethodDef[] methodDefs, ClassField[] fields, String[] names, String[] interfaces, String filename, int lineNumber)
      Create a class definition
      Parameters:
      packageName - The package name of the class (may be null)
      name - The name of the class
      access - Any access flags for the class (can be a sum of values from the Access class)
      methodDefs - The methods defined for this class
      fields - The fields defined for this class
      names - The names of each enum value
      interfaces - The interfaces this class implements
      filename - The source code filename this class was generated from
      lineNumber - The starting line number in the source code where this class is defined
  • Method Details

    • generateMethodDefs

      public static MethodDef[] generateMethodDefs(String className, MethodDef[] initialMethodDefs, ClassField[] fields, EnumInitializer[] initializers)
      Adds the required enum methods to the list of method definitions for this enum
      Parameters:
      className - The name of the enum class being generated
      initialMethodDefs - The method defs already defined for this enum
      fields - The fields for this enum
      initializers - The initializers for this enum
      Returns:
      The original method defs plus the methods required for an enum
    • generateEnumFields

      public static ClassField[] generateEnumFields(String className, ClassField[] fields, EnumInitializer[] initializers)
      Adds the class fields for the enum to the existing class fields
      Parameters:
      className - The class name being generated
      fields - The current class fields
      initializers - The enum initializers for this enum
      Returns:
      The original class fields with the enum field values added
    • generateInitializers

      public static EnumInitializer[] generateInitializers(String[] names)
      Creates a list of enum initializers for each enum value name
      Parameters:
      names - The names of the initializers to generate
      Returns:
      An array of the enum initializers