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
    Similar to java.lang.reflect
    This class is heavily used internally, and can be used (if needed) to modify Java Doc Web-Pages, programmatically.

    HTML Processors that sort the Web-Page "Summary-Tables" will provide instances of this class to your Summary-Sorter Handler methods. Summary-Sorter handlers usually implement the SummarySorterHelper interface; please review that class for more about sorting Java-Doc Page Summary Tables.

    The HTML Processors that upgrade Web-Page "Detail Elements" also rely heavily on this class. Please review the class: ReflHTML for more information about Java-Doc Web-Page Detail Sections.
    Reflection Class:
    Holds all information extracted from '.java' enum Source-Files about Enumerated-Constants's identified in that 'enum' file.

    Instances of this Class are Obtained From: ReflHTML & SummaryTableHTML

    Use of the Reflection-HTML API is *NOT REQUIRED* to perform a standard Java Doc HTML File Upgrade. This "extra API" allows for programmatic modification of Java Doc HTML. This class contains quite a bit of reflected information, and furthermore, here there is a hook to the Native Java Parser Reflection Class.
    Class EnumConstant allows for storing the name and (optional) initializations for an Enumerated Constant. These are found inside of a Java 'enum' Type-Definition.
    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

        🡅  🡇     🗕  🗗  🗖
        public final ReadOnlyList<java.lang.String> paramExpressions
        The parameters passed to the constructor that constructed the enumerated-constant instance.

        Many (or most) enum's do not actually use a constructor for their constants. Using a constructor is an extra-feature that allows additional information / data to be ascribed to the constant.

        If no constructor has been used to buid an Enumerated Constant, then there (obviously) wouldn't be any expressions passed to a constructor for that constant. In such cases, this field will contain a non-null, empty, ReadOnlyList<String>.
      • variableTree

        🡅  🡇     🗕  🗗  🗖
        public final transient com.sun.source.tree.VariableTree variableTree

        Hook Reference to Sun/Oracle Parser-Refletion Class

        Though this class offers a streamlined set of reflection features, the Native Oracle Library Reflection-Classes offer a detailed AST interface into the standard Java Compiler. If you would like to use these Tree's to provide further code analysis on your Java-Doc Pages, this field is provided as a convenience for such purposes.
        If a user decides to make use of the native Oracle VariableTree instance that was used to build this EnumConstant instance, it may be retrieved from this transient field.

        MethodTree Note:
        The package com.sun.source.tree "reuses" or "overloads" the VariableTree class in that it may represent either a Field, or an Enumerated-Constant.
    • Method Detail

      • 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:
        toString(int)
        Code:
        Exact Method Body:
         return
             "Name:        [" + name + "]\n" +
             "Declaration: [" + StrPrint.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" +
        
             // This will **NEVER** be null - unless 'this' instance was built from an HTML File,
             // rather than a source-code file.  Instances like that are only used temporarily, and
             // are garbage collected instantly.  Do this check anyway (just in case).
        
             "Location:    " + ((this.location == null)
                 ? "null" 
                 : ('[' + this.location.quickSummary() + ']'));
        
      • toString

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String toString​(int flags)
        This method accepts a 'flags' parameter which has been constructed using the Bit-Masks provided by the PF class. Please view the Static-Constants which are provided by class PF for more information about modifying the return-value of this toString(int) method.

        There is additional information printed by this 'toString' method (versus the zero-argument, standard, Java 'toString'). This method will print any available Java-Doc Comment's that were placed on this EnumConstant.

        This 'toString' also allows for adding UNIX-Terminal color codes.
        Overrides:
        toString in class Declaration
        Parameters:
        flags - These are defined in the Print-Flags class
        Returns:
        A printable String of this EnumConstant.
        See Also:
        PF, toString()
        Code:
        Exact Method Body:
         boolean color = (flags & UNIX_COLORS) > 0;
        
         return
             printedName("Enum-Const", 17, color) + 
             printedDeclaration(17, color) +
             printedParamExpressions(17) +
             printedLocation(17, color, (flags & BRIEF_LOCATION) > 0) +
        
             // The previous method does not add a '\n' end to the end of the returned string
             // This is optional, it adds a '\n' AT THE BEGINNING if it is included
        
             printedComments(17, color, (flags & JAVADOC_COMMENTS) > 0);
        
      • compareTo

        🡅  🡇     🗕  🗗  🗖
        public int compareTo​(EnumConstant ec)
        Java's interface Comparable<T> requirements. This does a very simple comparison using the two constants' Declaration.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 Comparable<EnumConstant> interface 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);