Class Main


public class Main extends Object
  • Field Details

    • outputFilePath

      private static String outputFilePath
    • topN

      private static int topN
    • classes

      private static List<Class<?>> classes
    • fieldsDeclared

      private static final Map<String,Integer> fieldsDeclared
    • fieldsAll

      private static final Map<String,Integer> fieldsAll
    • methodsAll

      private static final Map<String,Integer> methodsAll
    • methodsDeclared

      private static final Map<String,Integer> methodsDeclared
    • subtypesTotal

      private static final Map<String,Integer> subtypesTotal
    • supertypesTotal

      private static final Map<String,Integer> supertypesTotal
  • Constructor Details

    • Main

      public Main()
  • Method Details

    • main

      public static void main(String[] args)
    • inputClasses

      private static List<Class<?>> inputClasses(List<Class<?>> classes, String inputFilePath)
      Reads class names from the specified input file, loads each class, and adds it to the classes list.
      Parameters:
      classes - List to hold the loaded classes
      inputFilePath - Path to the file containing class names
      Returns:
      List of loaded classes
    • exploreHierarchy

      private static void exploreHierarchy(Class<?> clazz)
      Analyzes each class by counting its declared fields, methods, subtypes, and supertypes.
      Parameters:
      clazz - The class to be analyzed
    • exploreRecursive

      private static void exploreRecursive(Class<?> clazz, Set<String> uniqueFieldNames, Set<String> uniqueMethodNames, Set<String> supertypes)
      Recursively explores superclass and interfaces, adding inherited fields, methods, and supertypes.
      Parameters:
      clazz - The current class in the hierarchy
      uniqueFieldNames - Set of unique field names to track inherited fields
      uniqueMethodNames - Set of unique method names to track inherited methods
      supertypes - Set of supertypes for the current class
    • writeFile

      private static void writeFile(String outputFilePath, List<String> outputLines)
      Writes the formatted output data to the specified output file.
      Parameters:
      outputFilePath - Path to the output file
      outputLines - List of strings representing the formatted output data
    • sortMapByValueToString

      private static String sortMapByValueToString(Map<String,Integer> entries, int topN)
      Sorts a map by value in descending order and returns a formatted string of the top N entries.
      Parameters:
      entries - Map with class names as keys and counts as values
      topN - The maximum number of top entries to include
      Returns:
      Formatted string of the top N entries