Class HELPER


  • public class HELPER
    extends java.lang.Object
    Odds and ends, Wednesday Morning, 3 AM.


Stateless Class: This class neither contains any program-state, nor can it be instantiated. The @StaticFunctional Annotation may also be called 'The Spaghetti Report'. Static-Functional classes are, essentially, C-Styled Files, without any constructors or non-static member field. It is very similar to the Java-Bean @Stateless Annotation.
  • 1 Constructor(s), 1 declared private, zero-argument constructor
  • 14 Method(s), 14 declared static
  • 0 Field(s)


    • Method Summary

       
      Add HTML <META> Tags to a JavaDoc File
      Modifier and Type Method
      static void addMetaTags​(Vector<HTMLNode> page, Upgrade u, String dotDots)
       
      Find Files using a CLASSPATH String[] Array
      Modifier and Type Method
      static String findFileNameInClassPath​(String partialFileName, String[] rootSourceFileDirectories, boolean fileOrDirectory)
       
      Extract Static Fields from Java '.class' Files
      Modifier and Type Method
      static Field getStaticField​(Class<?> c, String fieldName, Class<?> expectedFieldType, String classFileName)
      static Object getStaticFieldEvaluation​(Field f, String classFileName)
       
      Java Parser Utilities
      Modifier and Type Method
      static Ret2<Integer,​Integer> countMethodsFields​(TypeDeclaration<?> td)
      static CIET getCIET​(TypeDeclaration<?> td)
      static String[] getExtendedTypes​(NodeList<type.ClassOrInterfaceType> extendedTypes)
      static String[] getGenericTypeParameters​(CompilationUnit cu, String name, CIET kind)
      static String[] getGenericTypeParameters​(NodeList<type.TypeParameter> genericTypeParameters)
      static String[] getImplementedTypes​(NodeList<type.ClassOrInterfaceType> implementedTypes)
      static Ret3<String,​String,​String> getInnerTypeNames​(TypeDeclaration<?> td)
      static String getPackageName​(CompilationUnit cu)
      static boolean isContainedByCorrectCIET​(Optional<Node> p, String name)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • addMetaTags

        🡇    
        public static void addMetaTags​(java.util.Vector<HTMLNode> page,
                                       Upgrade u,
                                       java.lang.String dotDots)
        If the user has provided HTML <META> or <LINK> tags to be inserted into the <HEAD> section of a Java Doc Page, this method will insert those tags.
        Parameters:
        page - The parsed, Vectorized Java Doc Web Page.
        u - The current instance of Upgrade
        dotDots - The relative path from the directory where the file is, to the root Java Doc Directory
        See Also:
        Upgrade.headerTags, TagNodeFind
        Code:
        Exact Method Body:
         TagNode favicon=null, cssFileLink=null;
        
         // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
         // Build the FAVICON <LINK> element.
         // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        
         if (u.faviconImageFileName != null)
         {
             // Retrieve the 'favicon' <LINK> element from the headerTags to insert list.
             favicon = (TagNode) u.headerTags.elementAt(Upgrade.FAV_HEADER_TAG_VEC_POS);
        
             // Insert a new 'favicon' with the correct relative-path string to the root
             // Java Doc directory.
             //
             // IMPORTANT: Do **NOT** clobber the original 'favicon' link, because the next insert
             //            (For another file) will need to do this String-Replace again!
             u.headerTags.setElementAt(
                 new TagNode(favicon.str.replace("DOTDOTS", dotDots)),
                 Upgrade.FAV_HEADER_TAG_VEC_POS
             );
         }
        
         // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
         // Build the JavaDoc.css <LINK> element
         // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        
         // Retrieve the 'JavaDoc.css' <LINK> element from the headerTags to insert list.
         cssFileLink = (TagNode) u.headerTags.elementAt(Upgrade.CSS_URL_HEADER_TAG_VEC_POS);
                
         // Insert a new 'CSS-File Link' with the correct relative-path string to the root
         // Java Doc directory.
         //
         // AGAIN: Do **NOT** clobber cssFileLink.  The next file will need the original one
         //        that has the String "DOTDOTS" so it can do the replacement for a differnt
         //        location
         u.headerTags.setElementAt(
             new TagNode(cssFileLink.str.replace("DOTDOTS", dotDots)),
             Upgrade.CSS_URL_HEADER_TAG_VEC_POS
         );
        
         // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
         // Find the HTML <HEAD> ... </HEAD> and insert the tags
         // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        
         int pos = TagNodeFind.first(page, TC.OpeningTags, "HEAD");
        
         if (pos == -1) if (Messager.isVerbose())
         {
             Messager.println(C.BRED + "Warning: No HTML <HEAD> tag found." + C.RESET);
             return;
         }
        
         // Add all to the position AFTER the <HEAD> tag
         page.addAll(pos + 1, u.headerTags);
        
         // Setup the 'headerTags' Vector for the next file.
         // SPECIFICALLY: Put original TagNode's back, because they have the replace-string
         u.headerTags.setElementAt(cssFileLink, Upgrade.CSS_URL_HEADER_TAG_VEC_POS);
        
         if (u.faviconImageFileName != null)
             u.headerTags.setElementAt(favicon, Upgrade.FAV_HEADER_TAG_VEC_POS);
        
         /*
         if (u.VERBOSE_PRINT_STEPS) u.messager.println(
             "\tInserted " + C.BBLUE + StringParse.zeroPad(u.headerTags.size(), 5) + C.RESET +
             " <META ...> Tags."
         );
         */
        
      • findFileNameInClassPath

        🡅  🡇    
        public static java.lang.String findFileNameInClassPath​
                    (java.lang.String partialFileName,
                     java.lang.String[] rootSourceFileDirectories,
                     boolean fileOrDirectory)
        
        Searches the root source directories for a particular file (or directory)
        Parameters:
        partialFileName - This String will be appended to the end of each & every one of the String's inside 'rootSourceFileDirectories' until a file-name that exists on the file-system has been found - or all root sorce-code directories have been checked for this 'partialFileName'
        rootSourceFileDirectories - This is the 'CLASSPATH', as it is implemented inside Java HTML.
        fileOrDirectory - If TRUE is passed, this will look for a file, and if FALSE is passed to this parameter, this method will look for a directory.
        Returns:
        This returns the
        Code:
        Exact Method Body:
         for (String rootSrcDir : rootSourceFileDirectories)
         {
             String fName = rootSrcDir + partialFileName;
        
             File f = new File(fName);
        
             // If this file exists, then a match has been found.  Just print the results to the
             // messager to let the user know, and copy this reference to "summarySorterClassFile"
             //
             // ALSO: Remember, there cannot be another file with the exact same name that was a
             //       directory (if this one is a file), and vice-versa... THEREFORE - return null
             //       if it is the wrong one.
        
             if (f.exists())
             {
                 if (fileOrDirectory)    return f.isFile()       ? fName : null;
                 else                    return f.isDirectory()  ? fName : null;
             }
         }
        
         return null;
        
      • getStaticField

        🡅  🡇    
        public static java.lang.reflect.Field getStaticField​
                    (java.lang.Class<?> c,
                     java.lang.String fieldName,
                     java.lang.Class<?> expectedFieldType,
                     java.lang.String classFileName)
        
        Retrieves an instance of java.lang.reflect.Field from a class, using soley the expected name of that field. Error checks are done to make sure that the field has been declared according to an "expected type". If it is not properly declared, then error messages are printed to the messager.
        Parameters:
        c - The class that ought to contain this field.
        fieldName - The name of a public and static field inside class 'c'. This field's reflection-mirror will be exgtracted.
        expectedFieldType - The type that the field is intended to be. If it is not of this type, or assignable-from this type, an error message is printed to the messager, and null is returned.
        classFileName - The file-name from whence class 'c' was loaded. This is strictly used by the messager in case of error.
        Returns:
        The java.lang.reflect.Field whose name is consistent with 'fieldName', and type is consistend with 'expectedFieldType'. If no such field exists, then null is returned.
        Code:
        Exact Method Body:
         java.lang.reflect.Field f = null;
        
         try 
             { f = c.getField(fieldName); }
        
         catch (NoSuchFieldException e)
         {
             Messager.errorContinue(
                 "User-Provided Source-Code Configuration-Class File:\n" +
                 "\t[" + C.BYELLOW + classFileName + C.RESET + "]\n" +
                 "There does not appear to contain a 'public' " +
                 C.BGREEN + expectedFieldType.getCanonicalName() + C.RESET + " Field named '" +
                 C.BGREEN + fieldName + C.RESET + "'.  Please review the documentation for this " +
                 "configuration-class."
             );
        
             return null;
         }
        
         catch (Exception e)
         {
             Messager.errorContinue(
                 e,
                 "User-Provided Source-Code Configuration-Class File:\n" +
                 "\t[" + C.BYELLOW + classFileName + C.RESET + "]\n" +
                 "An exception was thrown while attempting to access the " + 
                 C.BGREEN + expectedFieldType.getCanonicalName() + C.RESET + " Field named '" +
                 C.BGREEN + fieldName + C.RESET + "'."
             );
        
             return null;
         }
        
         if ((f.getModifiers() & java.lang.reflect.Modifier.STATIC) == 0)
         {
             Messager.errorContinue(
                 "User-Provided Source-Code Configuration-Class File:\n" +
                 "\t[" + C.BYELLOW + classFileName + C.RESET + "]\n" +
                 "Field [" + C.BGREEN + fieldName + C.RESET + "] was not declared 'static'"
             );
        
             return null;
         }
        
         Class<?> fieldType = f.getType();
        
         if (! expectedFieldType.isAssignableFrom(fieldType))
         {
             Messager.errorContinue(
                 "User-Provided Source-Code Configuration-Class File:\n" +
                 "\t[" + C.BYELLOW + classFileName + C.RESET + "]\n" +
                 "Field [" + C.BGREEN + fieldName + C.RESET + "] has a declared-type of '" +
                 C.BRED + fieldType.getCanonicalName() + C.RESET + "', but " +
                 "the type should be\n:\t" +
                 "'" + C.BGREEN + expectedFieldType.getCanonicalName() + C.RESET + "'."
             );
        
             return null;
         }
        
         else return f;
        
      • getStaticFieldEvaluation

        🡅  🡇    
        public static java.lang.Object getStaticFieldEvaluation​
                    (java.lang.reflect.Field f,
                     java.lang.String classFileName)
        
        This only real purpose of this method is to do BOTH consistent error-checking for all potential problems during the actual Field-lookup here, AND make sure that any error-messages printed (in the event of an error) are consistent and explanatory.

        USE: This method is used when reading the user-defined configuration-classes PackageSummarySort and ExtraHiLitedSrc that may be placed in their 'somePackageDir/upgrade-files/config-classes/' directories.
        Parameters:
        f - This is presumed to be a 'static' field inside of whatever class it was derived.

        NOTE: This method will not do any exception checks on the input-parameter 'f'. The name of this method does, indeed, imply that the passed field parameter 'f' must be a 'static' member of whatever 'class' in which it resides.
        classFileName - The only reason for passing this file-name String as a parameter here - is for error-printing purposes. This parameter needs to contain the original file-name of the '.class' file from which the Field parameter 'f' was retrieved.

        NOTE: At the time of the writing of this method, the feature which was being written that necessitated this method was one of the features where a User-Provided '.class'-File (one which acts as a "Configuration Class") is loaded from disk, and used to configure the feature. (These were 'SummarySorters' and 'ExtraHiLitedSrc').
        Returns:
        The value of the 'static' member-field 'f'
        Code:
        Exact Method Body:
         Object ret = null;
        
         // This needs to be checked, so that if there is a NullPointerException resulting from
         // attempting to evaluate 'f' on 'null' - BUT 'f' IS NOT STATIC...
         //
         // NOTE: Handled using an exception, rather than the messager, because it could only be
         //       thrown if somebody else was using this method.  My use of this will not call this
         //       method if the field is not found (and therefore null).
        
         if (f == null)
             throw new NullPointerException("You have passed null to Field parameter 'f'");
        
         // It is presumed that the field 'f' is a static field.  This means that there is no need
         // to evaluate this "field.get(...)" method using an object.  Passing 'null' here is how to
         // evaluate a 'java.lang.reflect.Field' when that field is declared using the 'static' 
         // modifier.
        
         try
             { ret = f.get(null); }
        
         // A "Java Acces Control Rule" (seems very unlikely - I don't have any idea, and it has
         // never happened to me, The Sun-Oracle Docs say it could possibly be thrown).  Note that
         // this is actually a "Checked Exception"
        
         catch (IllegalAccessException e)
         {
             Messager.errorContinue(
                 "Apparently a Java Language Access Control rule is being enforced, and the " +
                 "static " + ERROR_MESSAGE(f, classFileName) + "cannot be accessed."
             );
        
             return null;
         }
        
         // This actually could happen, theoretically, if the user had static-initializers
         // in his code.  This error is thrown when the 'Class' cannot be loaded by the ClassLoader
         // because of an error that occured in a "Static-Initializer"  - If you forgot what than is
         // it is Java Code that isn't inside a method, but rather a "static { ... code }" block
        
         catch (ExceptionInInitializerError e)
         {
             Throwable thrown = e.getException();
        
             Messager.errorContinue(
                 "While attempting to load " + ERROR_MESSAGE(f, classFileName) +
                 "Apparently there was an Exception or Throwable that was thrown inside of one " +
                 "of the static initializer's located inside that class" +
                 ((thrown != null) ? (":\n" + EXCC.toString(thrown, 4)) : "")
             );
        
             return null;
         }
        
         catch (NullPointerException e)
         {
             // Unless somebody else is using this little HELPER thing, this is essentially an
             // "UnreachableError" situation.  This could only be thrown if the Field was not
             // a "static" field, but rather an "instance" field.
             //
             // NOTE: For effeciency, this isn't checked at the top of this method.
             //
             // ALSO: The NPE Check at the top of this method is to make sure that *THIS* Field
             //       (parameter 'f') is NON-NULL.  However, if the field was an "instance" field,
             //       not a "static" field, according to the Java Sun/Oracle JavaDoc Page, then
             //       this exception would throw.  I'm changing the wording, and the exception name.
             //
             // NOTE: THIS STATEMENT IS UNREACHABLE - UNLESS FIELD IS NON-STATIC, BUT THAT WAS THE
             //       PRE-REQUISITE FOR USING THIS METHOD.
        
             throw new IllegalArgumentException(
                 "While attempting to load " + ERROR_MESSAGE(f, classFileName) +
                 "A NullPointerException was thrown when attempting to evaluate what was " +
                 "thought to be a 'static' java.lang.reflect.Field using field.get(null).  " +
                 "Did you check whether the Field had the 'static' modifier before asking this " +
                 "method to evaluate it.",
                 e
             );
         }
        
         // If this static field actually equals null, make sure to report that to the messager. 
         // This is only used for "User Configuration Classes" - and none of them really accept 
         // null as a value, and therefore it would always be tantamount to user error.
        
         if (ret == null)
         {
             Messager.errorContinue
                 (ERROR_MESSAGE(f, classFileName) + "the field evaluated to null.");
        
             return null;
         }
        
         return ret;
        
      • getCIET

        🡅  🡇    
        public static CIET getCIET​
                    (com.github.javaparser.ast.body.TypeDeclaration<?> td)
        
        Finds the "kind" of a type. The "kind" is one of many ways of expressing the word "type". "Type," thus-far, has been referred to by the acronym CIET. A "kind of type" is a class, interface, enum, annotation or record. This is the complete list of possible declarations from a '.java' source-code file.
        Parameters:
        td - A Java-Parser Type-Declaration. The sub-classes of TypeDeclaration include: ClassOrInterfaceDeclaration, EnumDeclaration, AnnotationDeclaration and RecordDeclaration.
        Returns:
        The CIET constant that maps to the Java-Parser type.
        Code:
        Exact Method Body:
         if (td.isEnumDeclaration())
             return CIET.ENUM;
        
         else if (td.isAnnotationDeclaration())
             return CIET.ANNOTATION;
        
         else if (td.isClassOrInterfaceDeclaration())
             return td.asClassOrInterfaceDeclaration().isInterface() ? CIET.INTERFACE : CIET.CLASS;
        
         // *** NOT-IMPLEMENTED YET ***
         // else if (td.isRecordDeclaration()) this.ciet = CIET.RECORD;
        
         return null;
        
      • getInnerTypeNames

        🡅  🡇    
        public static Ret3<java.lang.String,​java.lang.String,​java.lang.String> getInnerTypeNames​
                    (com.github.javaparser.ast.body.TypeDeclaration<?> td)
        
        Retrieves relevant name String's for an enclosed-class. Returned are the package-name, the fully-qualified name (not including the generic-type parameter's expression - <T, U>), and the name including all container-types.

        This method is only useful for classes that are enclosed by another class, specifically classes & types defined inside of another type '.java' file.
        Parameters:
        td - A Java-Parser Type-Declaration that is an inner-class (a type which is defined / enclosed by another type - for instance java.util.Map.Entry).
        Returns:
        Ret3<String, String, String> instance:

        • Ret3.a String
          Package-Name

        • Ret3.b String
          Class-Name, including *all* Enclosing-Classes

        • Ret3.c String
          Fully Qualified Name

        Code:
        Exact Method Body:
         String packageName = null;
        
         Optional<Node>  p   = td.getParentNode();
         StringBuilder   sb  = new StringBuilder();
        
         sb.append(td.getNameAsString());
         for (Node n; p.isPresent(); p = n.getParentNode())
         {
             n = p.get();
        
             if (n instanceof TypeDeclaration)
                 sb.insert(0, ((TypeDeclaration) n).getName().asString() + '.');
        
             if (n instanceof CompilationUnit)
                 packageName = getPackageName((CompilationUnit) n).trim();
         }
        
         String nameWithContainer = sb.toString().trim();
        
         String fullyQualifiedName =
             (((packageName != null) && (packageName.length() > 0))
                 ? (packageName + '.')
                 : "") +
             nameWithContainer;
        
         return new Ret3<>(packageName, nameWithContainer, fullyQualifiedName);
        
      • getPackageName

        🡅  🡇    
        public static java.lang.String getPackageName​
                    (com.github.javaparser.ast.CompilationUnit cu)
        
        Retrieves the Package-Name from an instance of Java-Parser class CompilationUnit
        Parameters:
        cu - Any Compilation Unit, but it must be one which was parsed from a complete source-file, otherwise the information will not have been made available to Java Parser (and will not be able to find the Package-Name)
        Returns:
        The Package-Name from whence cu was built, or null if there is no Package-Name or it was not found.
        Code:
        Exact Method Body:
         Optional<PackageDeclaration> optPD = cu.getPackageDeclaration();
         return optPD.isPresent() ? optPD.get().getName().asString().trim() : null;
        
      • getGenericTypeParameters

        🡅  🡇    
        public static java.lang.String[] getGenericTypeParameters​
                    (com.github.javaparser.ast.CompilationUnit cu,
                     java.lang.String name,
                     CIET kind)
        
        Retrieves the list of generic type parameters for a Class, Interface or Annotation.
        Parameters:
        cu - An instance of the Java Parser Type CompilationUnit, but one which was parsed from a complete '.java' source-code file. This method searches for a class, interface, annotation or record declaration.
        name - The name of the class, interface, annotation or record. This method will handle looking for the generic type-parameters of inner-classes / nested-types that have been defined in the '.java' file.
        kind - This must be either a. CIET.CLASS or a CIET.INTERFACE, since CIET.ANNOTATION and CIET.ENUM may not have generic type-parameters, and CIET.RECORD is not implemented yet.
        Returns:
        The list of generic type parameters defined in the type 'name' inside 'cu'.
        Code:
        Exact Method Body:
         // Here, the 'cu' is for the *ENTIRE* Java Source Code File.  It should be expected to have
         // it's 'name' field set to 'name' - **BUT** if this class or interface is a generic class
         // or interface, that 'name' will not have the Type-Parameter's in it!
         //
         // FOR INSTANCE: If this were class Torello.HTML.NodeSearch.HNLI<E> - This class would be
         //               found in the 'cu' using name-String 'HNLI' (without the 'E') This line
         //               just removes the 'E'
        
         name = name.replaceFirst("<.*>", "");
        
         // This 'cu' is from a **COMPLETE** Java Source Code File.  It must be either a class or
         // an interface.
        
         NodeList<TypeParameter> genericTypeParams = null;
         Optional<ClassOrInterfaceDeclaration> ocoid;
        
         // Optional<RecordDeclaration> ord; // Not implemented yet.
        
         switch (kind)
         {
             case CLASS:
                 genericTypeParams = (ocoid = cu.getClassByName(name)).isPresent()
                     ? ocoid.get().getTypeParameters()
                     : null;
                 break;
                    
             case INTERFACE:
                 genericTypeParams = (ocoid = cu.getInterfaceByName(name)).isPresent()
                     ? ocoid.get().getTypeParameters()
                     : null;
                 break;
        
             default: throw new IllegalArgumentException(
                 "You have passed " + kind.toString() + " to parameter kind, but this method " +
                 "only handles classes and interfaces"
             );
         }
        
         if (genericTypeParams == null) Messager.assertFailJavaParser
             ("Generic Type Parameters NodeList was null", kind.toString() + " " + name);
        
         // Create a new array.  For most classes / interfaces which do not have Generic
         // Type-Parameters (like the 'E' in Vector<E>), this String-array will have zero-length.
        
         String[] ret = new String[genericTypeParams.size()];
        
         // REMEMBER: The primary-goal of the Java-Parser classes in the Java-Doc Upgrader is just
         // to simplify the JP Code by extracting the information as simple Java String's.  Here,
         // the String's being extracted are the Type-Parameters.
        
         for (int i=0; i < genericTypeParams.size(); i++)
             ret[i] = genericTypeParams.get(i).asString().trim();
        
         return ret;
        
      • getGenericTypeParameters

        🡅  🡇    
        public static java.lang.String[] getGenericTypeParameters​
                    (com.github.javaparser.ast.NodeList<com.github.javaparser.ast.type.TypeParameter> genericTypeParameters)
        
        Builds a String[]-Array that contains all of the Generic-Type Parameters used by a Type
        Parameters:
        genericTypeParameters - A list of the Java Parser class TypeParameter
        Returns:
        The same list, but as a String[]-Array. This method will return null if the input list was null, or if it was empty.

        The individual String's are simply the ones returned by an invocation of TypeParameter.toString(). If wild-cards were used, the '?' will be retained, and if they were declared with upper bounds ('extends'), the extends-clause will also be included.
        Code:
        Exact Method Body:
         if ((genericTypeParameters != null) && (genericTypeParameters.size() > 0))
         {
             String[] ret = new String[genericTypeParameters.size()];
        
             for (int i=0; i < genericTypeParameters.size(); i++)
                 ret[i] = genericTypeParameters.get(i).toString().trim();
        
             return ret;
         }
        
         return null;
        
      • getImplementedTypes

        🡅  🡇    
        public static java.lang.String[] getImplementedTypes​
                    (com.github.javaparser.ast.NodeList<com.github.javaparser.ast.type.ClassOrInterfaceType> implementedTypes)
        
        Builds a String[]-Array that contains the type-names for the interface's that are implemented by a Type
        Parameters:
        implementedTypes - A list of the Java Parser class ClassOrInterfaceType
        Returns:
        The same list, but as a String[]-Array. This method will return null if the input list was null, or if it was empty. The individual String's that are returned in this array are passed through StringParse.typeToJavaIdentifier(String), and will adhere to the JOW: Just One Word type-name convention.
        See Also:
        StringParse.typeToJavaIdentifier(String)
        Code:
        Exact Method Body:
         if ((implementedTypes != null) && (implementedTypes.size() > 0))
         {
             String[] ret = new String[implementedTypes.size()];
        
             for (int i=0; i < implementedTypes.size(); i++)
                 ret[i] = StringParse.typeToJavaIdentifier
                     (implementedTypes.get(i).toString()).trim();
        
             return ret;
         }
        
         return null;
        
      • getExtendedTypes

        🡅  🡇    
        public static java.lang.String[] getExtendedTypes​
                    (com.github.javaparser.ast.NodeList<com.github.javaparser.ast.type.ClassOrInterfaceType> extendedTypes)
        
        Convenience Method
        Invokes: getImplementedTypes(NodeList)
        NOTE: The code for "Extended-Types" is identical to that for "Implemented-Interfaces".
        Code:
        Exact Method Body:
         return getImplementedTypes(extendedTypes);
        
      • countMethodsFields

        🡅  🡇    
        public static Ret2<java.lang.Integer,​java.lang.Integer> countMethodsFields​
                    (com.github.javaparser.ast.body.TypeDeclaration<?> td)
        
        Counts the number of methods and fields declared in any Java-Parser TypeDeclaration
        Parameters:
        td - A Java-Parser Type-Declaration. The sub-classes of TypeDeclaration include: ClassOrInterfaceDeclaration, EnumDeclaration, AnnotationDeclaration and RecordDeclaration.
        Returns:
        Ret2<Integer, Integer> instance:

        • Ret3.a Integer
          The Number of Methods Declared in td

        • Ret3.b Integer
          The Number of Fields Declared in td

        Code:
        Exact Method Body:
         // Same-Same: numFields are *FINAL* fields in this class, the counters are not.
         int numMethods=0, numFields=0;
        
         // A field or a method has to be a direct child of the TypeDeclaration
         for (Node n : td.getChildNodes())
        
             if (n instanceof MethodDeclaration)
                 numMethods++;
             else if (n instanceof FieldDeclaration)
                 numFields += ((FieldDeclaration) n).getVariables().size();
        
         return new Ret2<>(numMethods, numFields);
        
      • isContainedByCorrectCIET

        🡅    
        public static boolean isContainedByCorrectCIET​
                    (java.util.Optional<com.github.javaparser.ast.Node> p,
                     java.lang.String name)
        
        The Tree-Traversal algorithm / tree-walker for a JavaParser AST will visit all of the Methods, Constructors, and Enumerated-Types - even ones defined in inner classes. This checks that an instance of Node belongs to a class/type with a given name.
        Parameters:
        p - This is the (Optional) parent-node for any Java Parser Node instance. In. It may be retrieved by querying for the node's parent using the line below:

        Java Line of Code:
         p = n.getParentNode();
        
        name - The expected container class for the node in 'p'. This name must contain any and all container-class names, and cannot contain the full-package attached to it, nor any generic-type parameter information.

        This table depicts the exact name that should be passed to parameter 'name', in order to check that given node is a member node of the a particular type or inner-type.

        Fully-Qualified Type NameThis Parameter's Requirements
        java.lang.StringString
        java.util.Vector<E>Vector
        java.util.Iterator<E extends Iterable>Iterable
        Torello.Java.FileNode.RetTypeChoiceFileNode.RetTypeChoice
        java.util.Map.Entry<K, V>Map.Entry
        Returns:
        This will return TRUE if the parent/containing CIET where this node is defined is the correct CIET/Type having a name 'name'
        Code:
        Exact Method Body:
         StringBuilder foundCIETName = new StringBuilder();
        
         // This crawls "upwards" in the JavaParser AST for the Class, Interface or Enumerated
         // Type that contains the declared variable
        
         for (Node n; p.isPresent(); p = n.getParentNode())
         {
             String isInnerClass = (foundCIETName.length() > 0) ? "." : "";
             n = p.get();
        
             // 'ClassOrInterfaceDeclaration' is a JavaParser class
             if (n instanceof ClassOrInterfaceDeclaration)
                 foundCIETName.insert
                     (0, ((ClassOrInterfaceDeclaration) n).getName().asString() + isInnerClass);
        
             // 'EnumDeclaration' is a JavaParser class
             else if (n instanceof EnumDeclaration)
                 foundCIETName.insert
                     (0, ((EnumDeclaration) n).getName().asString() + isInnerClass);
        
             // 'AnnotationDeclaration' is a JavaParser class
             else if (n instanceof AnnotationDeclaration)
                 foundCIETName.insert
                     (0, ((AnnotationDeclaration) n).getName().asString() + isInnerClass);
         }
        
         // See above note about the 'name' and including the Generic Variable-Types in the
         // name.  The above getName().asString() from the JavaParser code does not include the
         // Generic Type Parameters in the name of the containing class.  Therefore, in this
         // comparison, they are left out.  There is no way a class could contain an inner-class
         // with the same-name, but different generic-type parameters.  It would be illegal.
        
         return foundCIETName.toString().equals(name);