Class EnumConstant

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<EnumConstant>

    public class EnumConstant
    extends Declaration
    implements java.io.Serializable, java.lang.Comparable<EnumConstant>, java.lang.Cloneable
    Java Parser Bridge: Holds all information extracted from '.java' enum Source Files about Enumerated Constants's identified in that 'enum' file.

    The purpose of this bridge is provide a pared down, easier-to-use (but-with less-features) version of the publicly available "JavaParser" package. This class EnumConstant allows for storing the name and (optional) initializations for an Enumerated Constant. These are found inside of a Java 'enum' type-definition.

    There is a Java-Parser Library that is required to use this Package. The Java Doc Upgrader Package / Tool will not work without this '.jar'file being placed in your CLASSPATH environment-variable. That '.jar'is available here:

    http://developer.torello.directory/ralphsReference/jars/javaparser-core-3.16.2.jar

    There is a book available and an internet "Gitter" support web-site chat-room with some of the people involved in writing this library. There are quite a number of available jars in the "Master Jar Distribution" - but the core library jar is fully sufficient for running the tasks needed by this Java-Doc Upgrade Tool's logic.

    Class Inheritance Diagram for Reflection Classes


    Class Declaration
     
    intid
    Entityentity
     
    Stringname
    Stringsignature
    StringjdComment
     
    String[]modifiers
    String[]annotations
     
    intsignatureLineNumber
    intjdStartLineNumber
    intjdEndLineNumber
     
     
     
     
     
    Class Callable
     
    Stringbody
     
    String[]parameterNames
    String[]parameterTypes
    String[]parameterTypesJOW
    String[][]parameterAnnotations
     
    String[]exceptions
     
     
     
     
     
    Class Method
     
    StringreturnType
    StringreturnTypeJOW
     
     
     
     
     
    Class Constructor
    Inherits Class Callable
    No Additional Fields
    Java Parser Bridge
    Inheritance Diagram


    Class Field
     
    Stringdefinition
    Stringtype
    StringtypeJOW
     
     
     
     
     
    Class EnumConstant
     
    String[]paramExpressions
     
     
     
     
     
    Class AnnotationElem
     
    StringdefaultValue
    Stringtype
    StringtypeJOW
     
     
     
     
     
    Class NestedType
     
    CIETciet
    intnumFields
    intnumMethods
     
    StringfullyQualifiedName
    StringnameWithContainer
    StringpackageName
     
    String[]extendedTypesJOW
    String[]implementedTypesJOW
    String[]genericTypeParameters
     
     
     
     
     




    IMPORTANT:
    All reflection classes above, also contain an additional (transient, non-Serializable) field that hooks into the native Java-Parser Library classes, providing an option for a more in-depth or complete analysis using that Library's features & extensive utilities.
    See Also:
    Serialized Form


    • Field Detail

      • serialVersionUID

        🡇    
        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
        public static final long serialVersionUID = 1;
        
      • paramExpressions

        🡅  🡇    
        protected final java.lang.String[] paramExpressions
        The parameters passed to the constructor that constructed the enumerated-constant instance.

        Many enum's do not use constructors for their constants - using a constructor is an extra-feature that allows other, informational data to be ascribed to the constant. If no constructor was used, then there (obviously) couldn't have been any expressions passed to a constructor for the constant. In such cases, this field will be null.

        NOTE: Access to the internal-arrays is restricted as 'protected' to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code '.java' file on disk.
        Code:
        Exact Field Declaration Expression:
        protected final String[] paramExpressions;
        
      • enumConstantDeclaration

        🡅  🡇    
        public final transient com.github.javaparser.ast.body.EnumConstantDeclaration enumConstantDeclaration
        If a user decides to make use of the Java-Parser EnumConstantDeclaration instance that was used to build this EnumConstant, it may be retrieved from this transient field.
        Code:
        Exact Field Declaration Expression:
        public final transient EnumConstantDeclaration enumConstantDeclaration;
        
    • Constructor Detail

      • EnumConstant

        🡅  🡇    
        public EnumConstant​
                    (com.github.javaparser.ast.body.EnumConstantDeclaration ecd)
        
        Instantiates a EnumConstant, and peels out the String's from a JavaParser EnumConstantDeclaration

        EXCEPTIONS NOTE: The underlying parser code can throw exceptions, and the exception chain, and exception tree in the package is quite dense. Suffice it to say, they are all unchecked exceptions.
        Parameters:
        ecd - This can be retrieved in any number of ways from the JavaParser package. The instantiation process will convert a Java-Parser from of an EnumConstantDeclaration, into this Bridge form class EnumConstant.

        Yes, this is redundant, but that's what a bridge is - a wrapper class to make the programmer's life easier. All the salient information a programmer would need when improving JavaDoc Documentation HTML Files is easily and simply encapsulated as lists of String's in the class EnumConstant.
    • Method Detail

      • getParamExpressions

        🡅  🡇    
        public java.lang.String[] getParamExpressions()
        Retrieves the list of 'paramExpressions' - which may or may not have been used to construct this constant - as String-array.
        Returns:
        An instance of String[] that employs the clone() method of the internal data-structure, protecting its contents. If this EnumConstant did not employ a constructor, or that constructor was a zero-argument constructor, then this method will return null.
        Code:
        Exact Method Body:
         return (paramExpressions != null) ? paramExpressions.clone() : null;
        
      • getParamExpressions

        🡅  🡇    
        public void getParamExpressions​
                    (java.util.function.Consumer<java.lang.String> acceptParamExpressionAsStringConsumer)
        
        Invokes a user-provided Consumer with each of the String's contained by the internal String[]-Array paramExpressions.
        Parameters:
        acceptParamExpressionAsStringConsumer - This should be any java.util.function.Consumer that will accept a reference from the getParamExpressions array, and perform whatever operations needed.
        See Also:
        paramExpressions
        Code:
        Exact Method Body:
         if (paramExpressions != null)
             for (String paramExpression : paramExpressions)
                 acceptParamExpressionAsStringConsumer.accept(paramExpression);
        
      • hasParamExpressions

        🡅  🡇    
        public boolean hasParamExpressions()
        Reports whether this instance of EnumConstant was constructed using a constructor that accepts parameters. This method simply returns whether or not the internal paramExpressions array is non-null and has length bigger than zero.
        Returns:
        Returns TRUE if there were any modifiers - public, static, final etc... - that were specified in this declaration.
        See Also:
        paramExpressions
        Code:
        Exact Method Body:
         return (paramExpressions != null) ? (paramExpressions.length > 0) : false;
        
      • numParamExpressions

        🡅  🡇    
        public int numParamExpressions()
        Return the number of parameters that are employed by the constructor that built this instance of EnumConstant. If a constructor was not used to build this constant, or if that constructor doesn't require or accept parameters, then this method simply returns 0.
        Returns:
        Returns the length of the protected (internal) paramExpressions array, or zero if that array is null.
        See Also:
        paramExpressions
        Code:
        Exact Method Body:
         return (paramExpressions != null) ? paramExpressions.length : 0;
        
      • toString

        🡅  🡇    
        public java.lang.String toString()
        Generates a String of this Enum Constant, with all information included.
        Overrides:
        toString in class Declaration
        Returns:
        A printable String of this EnumConstant.
        See Also:
        StrCSV.toCSV(String[], boolean, boolean, Integer), toString(int)
        Code:
        Exact Method Body:
         return
             "Name:         [" + name + "]\n" +
             "Declaration:  [" + StringParse.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" +
             "Line Numbers: [sig=" + signatureLineNumber + ", jdStart=" + jdStartLineNumber +
                                     ", jdEnd=" + jdEndLineNumber + "]";
        
      • toString

        🡅  🡇    
        public java.lang.String toString​(int flags)
        Generates a String of this EnumConst, with all information included. This will also included any content requested by the 'flags' parameter. For this class (EnumConstant), the only additional information printed by this 'toString' method is the Java-Doc Comment String.

        This String may also have UNIX color codes added.
        Overrides:
        toString in class Declaration
        Parameters:
        flags - These are the toString(...) flags from class PF ("Print Flags"). View available flags listed in class PF.
        Returns:
        A printable String of this AnnotationElem.
        See Also:
        PF, StrCSV.toCSV(String[], boolean, boolean, Integer), toString()
        Code:
        Exact Method Body:
         boolean color = (flags & UNIX_COLORS) > 0;
        
         return
             printedName("Enum-Const", 17, color) + 
             printedDeclaration(17, color) +
             printedParamExpressions(17) +
             printedLineNumbers(17, color) +
        
             // This are optional, it adds a '\n' AT THE BEGINNING if it is included
             printedComments(17, color, (flags & JAVADOC_COMMENTS) > 0);
        
      • clone

        🡅  🡇    
        public EnumConstant clone()
        Java's interface Cloneable requirements. This instantiates a new EnumConstant with identical fields.
        Overrides:
        clone in class java.lang.Object
        Returns:
        A new EnumConstant whose internal fields are identical to this one. A deep copy on all internal arrays is performed. New arrays are instantiated.
        Code:
        Exact Method Body:
         return new EnumConstant(this);
        
      • compareTo

        🡅  🡇    
        public int compareTo​(EnumConstant ec)
        Java's interface Comparable<T> requirements. This does a very simple comparison using the two constants' 'name' field.
        Specified by:
        compareTo in interface java.lang.Comparable<EnumConstant>
        Parameters:
        ec - Any other EnumConstant to be compared to 'this' EnumConstant
        Returns:
        An integer that fulfills Java's interface Comparable<EnumConstant> public boolean compareTo(EnumConstant ec) method requirements.
        Code:
        Exact Method Body:
         return (this == ec) ? 0 : this.name.compareTo(ec.name);
        
      • equals

        🡅    
        public boolean equals​(EnumConstant other)
        This should be called an "atypical version" of the usual equals(Object other) method. This version of equals merely compares the name of the constant defined. The presumption here is that the definition of an 'constant' only has meaning - at all - inside the context of an enum where that constant has been defined. Since inside any '.java' enum, there may only be one element with a given name, this method shall return TRUE whenever the constant being compared also has the same name.
        Parameters:
        other - This may be any other EnumConstant. It is strongly suggested that 'other' be a constant defined in the same '.java' source-code file as 'this' constant.
        Returns:
        This method returns TRUE when 'this' instance of EnumConstant has the same 'name' as the name of input-parameter 'other'
        Code:
        Exact Method Body:
         return this.name.equals(other.name);