Class NestedType

  • All Implemented Interfaces:
    java.io.Serializable

    public class NestedType
    extends Declaration
    Java Parser Bridge: Holds all information extracted from '.java' Source Files about Nested Types (Inner-Classes)

    Instances of this Class are Obtained From: JavaDocHTMLFile

    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.
    A Nested-Type may be any one of the primary types, including: Classes, Interfaces, Enum's, Annotations & Records. This class provides some reflected information about an inner-type retrieved using Java Parser.

    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

        🡇    
        protected 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:
        protected static final long serialVersionUID = 1;
        
      • ciet

        🡅  🡇    
        public final CIET ciet
        Identifies whether this is a nested/inner Class, Interface, Enum, Annotation etc...
        Code:
        Exact Field Declaration Expression:
        public final CIET ciet;
        
      • packageName

        🡅  🡇    
        public final java.lang.String packageName
        The name of the package in which the enclosing-class of this nested-type is defined. This field will be null if the package was not found, or left blank as the 'default class'.
        Code:
        Exact Field Declaration Expression:
        public final String packageName;
        
      • nameWithContainer

        🡅  🡇    
        public final java.lang.String nameWithContainer
        The name-field (Declaration.name) of this class uses the lone Java-Identifier (Just One Word) which identifies this NestedClass within the scope of the enclosing class. However, nameWithContainer is a String that also includes any / all enclosing-class names, each followed-by a '.'

        EXAMPLE: For Java java.util.Map.Entry<K, V>, the nameWithContainer would be "Map.Entry".

        Generic Type-Parameter information is not included in this String, and neither is the Package-Name.
        Code:
        Exact Field Declaration Expression:
        public final String nameWithContainer;
        
      • fullyQualifiedName

        🡅  🡇    
        public final java.lang.String fullyQualifiedName
        This field is identical to nameWithContainer, but also has the Package-Name prepended to it, if the Package-Name was present in the enclosing class' '.java' file.

        EXAMPLE: For Java java.util.Map.Entry<K, V>, the fullyQualifiedName would be "java.util.Map.Entry".
        Code:
        Exact Field Declaration Expression:
        public final String fullyQualifiedName;
        
      • numFields

        🡅  🡇    
        public final int numFields
        The number of fields that are defined in this inner-type
        Code:
        Exact Field Declaration Expression:
        public final int numFields;
        
      • numMethods

        🡅  🡇    
        public final int numMethods
        The number of methods defined in this inner-type
        Code:
        Exact Field Declaration Expression:
        public final int numMethods;
        
      • genericTypeParameters

        🡅  🡇    
        protected final java.lang.String[] genericTypeParameters
        A String[]-Array containing the actuala text of each / any / all type parameters utilized by this nested-type.

        If the inner-class being parsed were java.util.Map.Entry<K, V>, this array would have length 2. The two String's in this array would contain the single-character String's - "K" and "V".
        Code:
        Exact Field Declaration Expression:
        protected final String[] genericTypeParameters;
        
      • implementedTypesJOW

        🡅  🡇    
        protected final java.lang.String[] implementedTypesJOW
        A String[]-Array of the interface-names that this class implements. If this Nested-Type does not implement any interfaces, then this array will be null.

        JOW: Just One Word, The type-String's in this array are single Java-Identifiers that have had all package, container-class, and generic-parameter information removed from the type-name.

        If a NestedType implemented interface java.util.Iterator<HTMLNode>, the type-String representing it in this String[]-Array would simply be "Iterator". JOW: Just One Word

        If the String's in a type-as-String contain complicated or intricate detailed information, and all you need is a simple identifier, the JOW-String stores the type-as-String with all package-name and generic-parameters (if they were present / included) stripped from the String. Furthermore, if the type was originally an inner-class, even the containing class-name is removed from the JOW-String.

        If a parameter to a Method, or the type of a Field had the (fully-qualified) type-name: java.util.stream.Stream.Builder<String>, the JOW-String would simply have the word "Builder".

        NOTE: If the type, itself, is an array of any kind, the array-brackets will be included in this String-name.
        Output Single-Word, Type-StringInput Type
        "Entry" "java.util.Map.Entry<K, V>"
        "Vector" "java.util.Vector<E>"
        "Vector" "Vector<TagNode>"
        "Vector" "Vector<Vector<TagNode>>"
        "Vector" "java.util.Vector<Vector<TagNode>>"
        "String" "String"
        "String" "java.lang.String"
        "String[]" "java.lang.String[]"
        "Integer" "Integer"
        "Integer[]" "java.lang.Integer[]"

        NOTE: You may view the StringParse class' methods removeGeneric, and typeToJavaIdentifier for more information.
        Code:
        Exact Field Declaration Expression:
        protected final String[] implementedTypesJOW;
        
      • extendedTypesJOW

        🡅  🡇    
        protected final java.lang.String[] extendedTypesJOW
        A String[]-Array of the types that this class extends. If this Nested-Type does not extend any classes, then this array will be null.

        JOW: Just One Word, The type-String's in this array are single Java-Identifiers that have had all package, container-class, and generic-parameter information removed from the type-name.

        If a NestedType extended class java.util.Map.Entry<K, V>, the type-String representing it in this String[]-Array would simply be "Entry".
        Code:
        Exact Field Declaration Expression:
        protected final String[] extendedTypesJOW;
        
      • typeDeclaration

        🡅  🡇    
        public final transient com.github.javaparser.ast.body.TypeDeclaration<?> typeDeclaration

        Hook Reference to Java-Parser Refletion Class

        Though this class offers a streamlined set of reflection features, the Native Java-Parser Library Reflection-Classes offer a near-complete set of analysis tools for just about any kind of code-analysis neccessary. If you would like your Java Doc Pages to include more analytical-information, this field is provided as a convenience for such purposes.
        If a user decides to make use of the Java-Parser TypeDeclaration instance that was used to build this NestedType, it may be retrieved from this transient field.
        Code:
        Exact Field Declaration Expression:
        public final transient TypeDeclaration<?> typeDeclaration;
        
    • Constructor Detail

      • NestedType

        🡅  🡇    
        public NestedType​(com.github.javaparser.ast.body.TypeDeclaration<?> td,
                          CIET ciet)
        Constructs an instance of this class
        Parameters:
        td - Any Java Parser instance of TypeDeclaration
        ciet - The kind of TypeDeclaration this is.
    • Method Detail

      • numTypesImplemented

        🡅  🡇    
        public int numTypesImplemented()
        The number of types listed among the types in the 'implements' clause of this inner-type's declaration.
        Returns:
        The number of types which this NestedType implements
        See Also:
        implementedTypesJOW
        Code:
        Exact Method Body:
         return (this.implementedTypesJOW != null)
             ? this.implementedTypesJOW.length
             : 0;
        
      • numTypesExtended

        🡅  🡇    
        public int numTypesExtended()
        The number of types listed among the types in the 'extends' clause of this inner-type's declaration.
        Returns:
        The number of types which this NestedType extends
        See Also:
        extendedTypesJOW
        Code:
        Exact Method Body:
         return (this.extendedTypesJOW != null)
             ? this.extendedTypesJOW.length
             : 0;
        
      • numGenericTypeParameters

        🡅  🡇    
        public int numGenericTypeParameters()
        The number of generic type-parameters declared by this NestedType. If this class is not a generic-type, then zero is returned, gracefully.
        Returns:
        The number of generic type-parameters in the signature-declaration of this inner-class.
        See Also:
        genericTypeParameters
        Code:
        Exact Method Body:
         return (this.genericTypeParameters != null)
             ? this.genericTypeParameters.length
             : 0;
        
      • implementsType

        🡅  🡇    
        public boolean implementsType​(java.lang.String implementedTypeJOW)
        Checks whether this NestedType implements a particular interface
        Returns:
        TRUE, if and only if the protected-internal implementedTypesJOW array contains input-parameter 'implementedTypeJOW'
        See Also:
        implementedTypesJOW
        Code:
        Exact Method Body:
         if (this.implementedTypesJOW != null)
             for (String type : this.implementedTypesJOW)
                 if (type.equals(implementedTypeJOW)) return true;
        
         return false;
        
      • extendsType

        🡅  🡇    
        public boolean extendsType​(java.lang.String extendedTypeJOW)
        A list of all types extended by this NestedType
        Returns:
        A clone of the protected-internal extendedTypesJOW array.
        See Also:
        implementedTypesJOW
        Code:
        Exact Method Body:
         if (this.extendedTypesJOW != null)
             for (String type : this.extendedTypesJOW)
                 if (type.equals(extendedTypeJOW)) return true;
        
         return false;
        
      • getGenericTypeParameters

        🡅  🡇    
        public java.lang.String[] getGenericTypeParameters()
        A list of all generic type-parameters declared by this NestedType

        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.
        Returns:
        A clone of the protected-internal genericTypeParameters array, or null if this inner-type is not a generic-type.
        Code:
        Exact Method Body:
         return (this.genericTypeParameters != null)
             ? this.genericTypeParameters.clone()
             : null;
        
      • getImplementedTypesJOW

        🡅  🡇    
        public java.lang.String[] getImplementedTypesJOW()
        A list of all types implemented by this NestedType

        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.
        Returns:
        A clone of the protected-internal implementedTypesJOW array, or null if this inner-type does not implement any interfaces.
        See Also:
        implementedTypesJOW
        Code:
        Exact Method Body:
         return (this.implementedTypesJOW != null)
             ? this.implementedTypesJOW.clone()
             : null;
        
      • getExtendedTypesJOW

        🡅  🡇    
        public java.lang.String[] getExtendedTypesJOW()
        A list of all types extended by this NestedType\

        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.
        Returns:
        A clone of the protected-internal extendedTypesJOW array, or null if this inner-type does not extend any other types.
        See Also:
        implementedTypesJOW
        Code:
        Exact Method Body:
         return (this.extendedTypesJOW != null)
             ? this.extendedTypesJOW.clone()
             : null;
        
      • getGenericTypeParameters

        🡅  🡇    
        public void getGenericTypeParameters​
                    (java.util.function.Consumer<java.lang.String> acceptGenericTypeParamsAsStringConsumer)
        
        Provides the list of genericTypeParameters to a user-provided java.util.function.Consumer<String[]>

        If this Method or Constructor is not a generic-type, and does not declare any generic type-parameters, this method exits gracefully.

        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.
        Parameters:
        acceptGenericTypeParamsAsStringConsumer - This should be any java.util.function.Consumer that will accept a reference from the genericTypeParameters array, and perform whatever operations needed.
        See Also:
        genericTypeParameters
        Code:
        Exact Method Body:
         if (genericTypeParameters != null)
             for (String genericTypeParameter : genericTypeParameters)
                 acceptGenericTypeParamsAsStringConsumer.accept(genericTypeParameter);
        
      • getExtendedTypesJOW

        🡅  🡇    
        public void getExtendedTypesJOW​
                    (java.util.function.Consumer<java.lang.String> acceptExtendedTypesJOWAsStringConsumer)
        
        Provides the list of extendedTypesJOW to a user-provided java.util.function.Consumer<String[]>

        If this NestedType does not extend and types, this method exits gracefully.

        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.
        Parameters:
        acceptExtendedTypesJOWAsStringConsumer - This should be any java.util.function.Consumer that will accept a reference from the extendedTypesJOW array, and perform whatever operations needed.
        See Also:
        extendedTypesJOW
        Code:
        Exact Method Body:
         if (extendedTypesJOW != null)
             for (String extendedTypeJOW : extendedTypesJOW)
                 acceptExtendedTypesJOWAsStringConsumer.accept(extendedTypeJOW);
        
      • getImplementedTypesJOW

        🡅  🡇    
        public void getImplementedTypesJOW​
                    (java.util.function.Consumer<java.lang.String> acceptImplementedTypesJOWAsStringConsumer)
        
        Provides the list of implementedTypesJOW to a user-provided java.util.function.Consumer<String[]>

        If this NestedType does not extend and types, this method exits gracefully.

        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.
        Parameters:
        acceptImplementedTypesJOWAsStringConsumer - This should be any java.util.function.Consumer that will accept a reference from the implementedTypesJOW array, and perform whatever operations needed.
        See Also:
        implementedTypesJOW
        Code:
        Exact Method Body:
         if (implementedTypesJOW != null)
             for (String implementedTypeJOW : implementedTypesJOW)
                 acceptImplementedTypesJOWAsStringConsumer.accept(implementedTypeJOW);
        
      • toString

        🡅  🡇    
        public java.lang.String toString()
        Generates a String of this nested-type, with most information included.
        Overrides:
        toString in class Declaration
        Returns:
        A printable String of this nested-type.
        See Also:
        PF, toString(int), StrCSV.toCSV(String[], boolean, boolean, Integer)
        Code:
        Exact Method Body:
         return
             "Name:            [" + name + "]\n" +
             "With Container:  [" + nameWithContainer + "]\n" +
             "Kind:            [" + ciet.toString() + "]\n" +
             "Signature:       [" +
                 StringParse.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" +
        
             // "Type Parameters:".length() ==>  16  (17=16+1)
             printedTypeParameters(17) +
        
             "Modifiers:       [" +
                 StrCSV.toCSV(modifiers, true, true, null) + "]\n" +
        
             "Line-Numbers:    [sig=" + signatureLineNumber + ", jdStart=" + jdStartLineNumber +
                 ", jdEnd=" + jdEndLineNumber + "]";
        
      • toString

        🡅  🡇    
        public java.lang.String toString​(int flags)
        This class expects a flags that has been masked using the constant (public, static, final int) fields of class PF. Please view this class for more information about the flags available for modifying the return-value of this toString() method.
        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 method, with comment information included as well.
        See Also:
        StrCSV.toCSV(String[], boolean, boolean, Integer), toString(), PF
        Code:
        Exact Method Body:
         boolean color = (flags & UNIX_COLORS) > 0;
         String nameTitle = "Nested " + ciet.toString();
        
         // 7 ==> " Name: ".length()
         int LEN = nameTitle.length() + 7;
        
         return 
             printedName(nameTitle, LEN, color) +
             StringParse.rightSpacePad("Fully Qualified:", LEN) + '[' + fullyQualifiedName + "]\n" +
             StringParse.rightSpacePad("With Container:", LEN) + '[' + nameWithContainer + "]\n" +
             printedSignature(LEN, color) +
             printedTypeParameters(LEN) +
             printedModifiers(LEN) +
             printedExtendsImplements(LEN) +
             printedMethodField(LEN, color) + 
             printedLineNumbers(LEN, color) +
             // These are optional, they add a '\n' AT THE BEGINNING if they are included
             printedComments(LEN, color, (flags & JAVADOC_COMMENTS) > 0);
        
      • clone

        🡅  🡇    
        public NestedType clone()
        Java's interface Cloneable requirements. This instantiates a new NestedType with identical fields.
        Overrides:
        clone in class java.lang.Object
        Returns:
        A new NestedType 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 NestedType(this);
        
      • compareTo

        🡅  🡇    
        public int compareTo​(NestedType nt)
        Java's interface Comparable<T> requirements. This does a very simple comparison using the two nested-types's 'name' field.
        Parameters:
        nt - Any other Nested-Type to be compared to 'this'
        Returns:
        An integer that fulfills Java's interface Comparable<NestedType>, public boolean compareTo(NestedType nt) method requirements.
        Code:
        Exact Method Body:
         return (this == nt) ? 0 : this.name.compareTo(nt.name);
        
      • equals

        🡅    
        public boolean equals​(NestedType 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 field defined. The presumption here is that the definition of a 'field' only has meaning - at all - inside the context of a class, interface, or enumerated-type where that field is defined. Since inside any '.java' source-code file, there may only be one field with a given name, this method shall return TRUE whenever the field being compared also has the same name.
        Parameters:
        other - This may be any other field. It is strongly suggested that 'other' be a field defined in the same '.java' source-code file as 'this' field.
        Returns:
        This method returns TRUE when 'this' instance of Field has the same 'name' as the name-field of input-parameter 'other'
        Code:
        Exact Method Body:
         return this.name.equals(other.name);