Package org.djutils.test
Class ClassList
java.lang.Object
org.djutils.test.ClassList
ClassList contains two helper methods that check whether all classes in a package implement a given interface or method.
Copyright (c) 2025-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Method Summary
Modifier and TypeMethodDescriptionclassesWithoutInterface
(Class<?> interfaceClass, String... packageNameList) Return a list with the class names that do not implement the given interface.classesWithoutMethod
(String methodName, String... packageNameList) Return a list with the class names without an explicitly declared method.static void
Walk the path names and make two lists: one of the classes that do not implement toString() and one of the classes that do not implement the interface Serializable.static void
printClassesWithoutInterface
(Class<?> interfaceClass, String... packageNameList) Prints a list with the class names that do not implement the given interface.static void
printClassesWithoutMethod
(String methodName, String... packageNameList) Prints a list with the class names without an explicitly declared method.
-
Method Details
-
classesWithoutMethod
Return a list with the class names without an explicitly declared method. By default, the check ignores anonymous inner classes, but includes explicit local or static inner classes. It only looks at classes, not at interfaces, records, annotation classes or enums.- Parameters:
methodName
- the method to check forpackageNameList
- a list of package names to check- Returns:
- a list of classes within the given packages without a toString() method
-
printClassesWithoutMethod
Prints a list with the class names without an explicitly declared method. By default, the check ignores anonymous inner classes, but includes explicit local or static inner classes. It only looks at classes, not at interfaces, records, annotation classes or enums.- Parameters:
methodName
- the method to check forpackageNameList
- a list of package names to check
-
classesWithoutInterface
public static List<String> classesWithoutInterface(Class<?> interfaceClass, String... packageNameList) Return a list with the class names that do not implement the given interface. By default, the check ignores anonymous inner classes, but includes explicit local or static inner classes. It only looks at classes, not at interfaces, records, annotation classes or enums.- Parameters:
interfaceClass
- the interface to check forpackageNameList
- a list of package names to check- Returns:
- a list of classes within the given packages that do not implement the provided interface
-
printClassesWithoutInterface
Prints a list with the class names that do not implement the given interface. By default, the check ignores anonymous inner classes, but includes explicit local or static inner classes. It only looks at classes, not at interfaces, records, annotation classes or enums.- Parameters:
interfaceClass
- the interface to check forpackageNameList
- a list of package names to check
-
main
Walk the path names and make two lists: one of the classes that do not implement toString() and one of the classes that do not implement the interface Serializable.- Parameters:
args
- can contain the package name(s) to inspect; org.djutils will be taken if the args are empty
-