Package org.jfuncmachine.compiler.model
Class EnumDef
java.lang.Object
org.jfuncmachine.compiler.model.SourceElement
org.jfuncmachine.compiler.model.ClassDef
org.jfuncmachine.compiler.model.EnumDef
A definition for an num, containing methods, fields, the names of interfaces that are implemented,
and enum value constructors
-
Field Summary
Fields inherited from class org.jfuncmachine.compiler.model.ClassDef
access, fields, interfaces, methodDefs, name, packageName, superName, superPackageNameFields inherited from class org.jfuncmachine.compiler.model.SourceElement
filename, lineNumber -
Constructor Summary
ConstructorsConstructorDescriptionEnumDef(String packageName, String name, int access, MethodDef[] methodDefs, ClassField[] fields, String[] names, String[] interfaces) Create a class definitionEnumDef(String packageName, String name, int access, MethodDef[] methodDefs, ClassField[] fields, String[] names, String[] interfaces, String filename, int lineNumber) Create a class definitionEnumDef(String packageName, String name, int access, MethodDef[] methodDefs, ClassField[] fields, EnumInitializer[] initializers, String[] interfaces) Create a class definitionEnumDef(String packageName, String name, int access, MethodDef[] methodDefs, ClassField[] fields, EnumInitializer[] initializers, String[] interfaces, String filename, int lineNumber) Create a class definition -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassField[]generateEnumFields(String className, ClassField[] fields, EnumInitializer[] initializers) Adds the class fields for the enum to the existing class fieldsstatic EnumInitializer[]generateInitializers(String[] names) Creates a list of enum initializers for each enum value namestatic MethodDef[]generateMethodDefs(String className, MethodDef[] initialMethodDefs, ClassField[] fields, EnumInitializer[] initializers) Adds the required enum methods to the list of method definitions for this enumMethods inherited from class org.jfuncmachine.compiler.model.ClassDef
getFullClassNameMethods inherited from class org.jfuncmachine.compiler.model.SourceElement
generateException
-
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 classaccess- Any access flags for the class (can be a sum of values from the Access class)methodDefs- The methods defined for this classfields- The fields defined for this classinitializers- The initializers for each enum valueinterfaces- 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 classaccess- Any access flags for the class (can be a sum of values from the Access class)methodDefs- The methods defined for this classfields- The fields defined for this classinitializers- The initializers for each enum valueinterfaces- The interfaces this class implementsfilename- The source code filename this class was generated fromlineNumber- 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 classaccess- Any access flags for the class (can be a sum of values from the Access class)methodDefs- The methods defined for this classfields- The fields defined for this classnames- The names of each enum valueinterfaces- 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 classaccess- Any access flags for the class (can be a sum of values from the Access class)methodDefs- The methods defined for this classfields- The fields defined for this classnames- The names of each enum valueinterfaces- The interfaces this class implementsfilename- The source code filename this class was generated fromlineNumber- 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 generatedinitialMethodDefs- The method defs already defined for this enumfields- The fields for this enuminitializers- 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 generatedfields- The current class fieldsinitializers- The enum initializers for this enum- Returns:
- The original class fields with the enum field values added
-
generateInitializers
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
-