Class Main
java.lang.Object
Main
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidexploreHierarchy(Class<?> clazz) Analyzes each class by counting its declared fields, methods, subtypes, and supertypes.private static voidexploreRecursive(Class<?> clazz, Set<String> uniqueFieldNames, Set<String> uniqueMethodNames, Set<String> supertypes) Recursively explores superclass and interfaces, adding inherited fields, methods, and supertypes.inputClasses(List<Class<?>> classes, String inputFilePath) Reads class names from the specified input file, loads each class, and adds it to the classes list.static voidprivate static StringsortMapByValueToString(Map<String, Integer> entries, int topN) Sorts a map by value in descending order and returns a formatted string of the top N entries.private static voidWrites the formatted output data to the specified output file.
-
Field Details
-
outputFilePath
-
topN
private static int topN -
classes
-
fieldsDeclared
-
fieldsAll
-
methodsAll
-
methodsDeclared
-
subtypesTotal
-
supertypesTotal
-
-
Constructor Details
-
Main
public Main()
-
-
Method Details
-
main
-
inputClasses
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 classesinputFilePath- Path to the file containing class names- Returns:
- List of loaded classes
-
exploreHierarchy
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 hierarchyuniqueFieldNames- Set of unique field names to track inherited fieldsuniqueMethodNames- Set of unique method names to track inherited methodssupertypes- Set of supertypes for the current class
-
writeFile
Writes the formatted output data to the specified output file.- Parameters:
outputFilePath- Path to the output fileoutputLines- List of strings representing the formatted output data
-
sortMapByValueToString
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 valuestopN- The maximum number of top entries to include- Returns:
- Formatted string of the top N entries
-