Class ClassSelector

java.lang.Object
io.vertigo.core.lang.ClassSelector

public final class ClassSelector extends Object
Utility class for selecting and filtering classes through reflection. Provides a fluent API for: - 1. Defining class scope by packages or explicit classes - 2. Filtering classes, methods and fields by predicates - 3. Finding matching elements with type safety - Supporting annotation-based filtering - Enabling component scanning and introspection Usage example: ClassSelector.from("com.example") .filterClasses(ClassConditions.annotatedWith(MyAnnotation.class)) .filterMethods(MethodConditions.annotatedWith(MyMethodAnnotation.class)) .findMethods();
Author:
mlaroche
  • Method Details

    • from

      public static ClassSelector from(Collection<Class> classes)
      Adds a set of classes to the scope.
      Parameters:
      classes - a supplier of classes
      Returns:
      the selector
    • from

      public static ClassSelector from(Class clazz)
      Adds a class to the scope.
      Parameters:
      clazz - the class to add
      Returns:
      the selector
    • from

      public static ClassSelector from(String packageName)
      Adds all the classes with a package prefix in the scope.
      Parameters:
      packageName - the root package
      Returns:
      the selector
    • filterFields

      public ClassSelector filterFields(Predicate<Field> fieldPredicate)
      Filters field with a predicate.
      Parameters:
      fieldPredicate - the predicate
      Returns:
      the selector
    • filterMethods

      public ClassSelector filterMethods(Predicate<Method> methodPredicate)
      Filters method with a predicate.
      Parameters:
      methodPredicate - the predicate
      Returns:
      the selector
    • filterClasses

      public ClassSelector filterClasses(Predicate<Class> classPredicate)
      Filters classes with a predicate.
      Parameters:
      classPredicate - the predicate
      Returns:
      the selector
    • findClasses

      public Collection<Class> findClasses()
      Find the classes matching the requirements and with method matching the requirements.
      Returns:
      the classes matching the selector
    • findMethods

      public Collection<Tuple<Class,Method>> findMethods()
      Find the methods matching the requirements and with method matching the requirements.
      Returns:
      the classes matching the selector
    • findFields

      public Collection<Tuple<Class,Field>> findFields()
      Finds the fields matching the requirements with the associatedClass.
      Returns:
      the classes matching the selector