org.springframework.web.method

## Class HandlerTypePredicate

- java.lang.Object
- - org.springframework.web.method.HandlerTypePredicate

- All Implemented Interfaces:
    Predicate<Class<?>>

      public final class HandlerTypePredicate
      extends Object
      implements Predicate<Class<?>>

  A `Predicate` to match request handling component types if any of the following selectors match:
  - Base packages -- for selecting handlers by their package.
  - Assignable types -- for selecting handlers by supertype.
  - Annotations -- for selecting handlers annotated in a specific way.

  Composability methods on `Predicate` can be used :

       Predicate<Class<?>> predicate =
                      HandlerTypePredicate.forAnnotation(RestController.class)
                                      .and(HandlerTypePredicate.forBasePackage("org.example"));

  Since:
    5.1
  Author:
    Rossen Stoyanchev

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `HandlerTypePredicate.Builder` A `HandlerTypePredicate` builder.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static HandlerTypePredicate.Builder` | `builder()` Return a builder for a `HandlerTypePredicate`.
    `static HandlerTypePredicate` | `forAnnotation(Class<? extends Annotation>... annotations)` Match handlers annotated with a specific annotation.
    `static HandlerTypePredicate` | `forAnyHandlerType()` `Predicate` that applies to any handlers.
    `static HandlerTypePredicate` | `forAssignableType(Class<?>... types)` Match handlers that are assignable to a given type.
    `static HandlerTypePredicate` | `forBasePackage(String... packages)` Match handlers declared under a base package, e.g.
    `static HandlerTypePredicate` | `forBasePackageClass(Class<?>... packageClasses)` Type-safe alternative to `forBasePackage(String...)` to specify a base package through a class.
    `boolean` | `test(Class<?> controllerType)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.function.Predicate

      `and, isEqual, negate, or`

- - ### Method Detail

    - #### test

          public boolean test(@Nullable
                              Class<?> controllerType)

      Specified by:
        `test` in interface `Predicate<Class<?>>`

    - #### forAnyHandlerType

          public static HandlerTypePredicate forAnyHandlerType()

      `Predicate` that applies to any handlers.

    - #### forBasePackage

          public static HandlerTypePredicate forBasePackage(String... packages)

      Match handlers declared under a base package, e.g. "org.example".
      Parameters:
        `packages` - one or more base package names

    - #### forBasePackageClass

          public static HandlerTypePredicate forBasePackageClass(Class<?>... packageClasses)

      Type-safe alternative to `forBasePackage(String...)` to specify a base package through a class.
      Parameters:
        `packageClasses` - one or more base package classes

    - #### forAssignableType

          public static HandlerTypePredicate forAssignableType(Class<?>... types)

      Match handlers that are assignable to a given type.
      Parameters:
        `types` - one or more handler supertypes

    - #### forAnnotation

          @SafeVarargs
          public static HandlerTypePredicate forAnnotation(Class<? extends Annotation>... annotations)

      Match handlers annotated with a specific annotation.
      Parameters:
        `annotations` - one or more annotations to check for

    - #### builder

          public static HandlerTypePredicate.Builder builder()

      Return a builder for a `HandlerTypePredicate`.