Class ClassList

java.lang.Object
org.djutils.test.ClassList

public final class ClassList extends Object
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 Details

    • classesWithoutMethod

      public static List<String> classesWithoutMethod(String methodName, String... packageNameList)
      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 for
      packageNameList - a list of package names to check
      Returns:
      a list of classes within the given packages without a toString() method
    • printClassesWithoutMethod

      public static void printClassesWithoutMethod(String methodName, String... packageNameList)
      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 for
      packageNameList - 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 for
      packageNameList - a list of package names to check
      Returns:
      a list of classes within the given packages that do not implement the provided interface
    • printClassesWithoutInterface

      public static void printClassesWithoutInterface(Class<?> interfaceClass, String... packageNameList)
      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 for
      packageNameList - a list of package names to check
    • main

      public static void main(String... args)
      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