Class TypedFilter<T>

java.lang.Object
de.espirit.common.TypedFilter<T>
All Implemented Interfaces:
Filter<T>, Filter.TypedFilter<T>, Serializable

public abstract class TypedFilter<T> extends Object implements Filter.TypedFilter<T>
Abstract typed filter definition providing base mechanisms and factories to easily create specific kinds of filters based on its specific object type.
Since:
4.0.17
See Also:
  • Constructor Details

    • TypedFilter

      public TypedFilter(@NotNull @NotNull Class<T> type)
      Base constructor for filters based on the given type.
      Parameters:
      type - The object type filtering on.
      Since:
      4.0.17
  • Method Details

    • filter

      @Nullable public T filter(@Nullable @Nullable Object element)
      Filter the given element and return either an object of this classes type T or null, if the element does not match the filter as defined by Filter.accept(Object).
      Specified by:
      filter in interface Filter.TypedFilter<T>
      Parameters:
      element - The element to be filtered.
      Returns:
      The correctly typed element or null.
      Since:
      4.0.17
    • getType

      @NotNull public final @NotNull Class<T> getType()
      Get the filter type.
      Specified by:
      getType in interface Filter.TypedFilter<T>
      Returns:
      The filter type.
      Since:
      4.0.17
    • create

      public static <T> TypedFilter<T> create(@NotNull @NotNull Class<T> type)
      Creates and returns a class based type filter with no additional conditions.
      Parameters:
      type - The type to check for.
      Returns:
      The created type filter.
      Since:
      4.0.17
    • create

      public static <T> TypedFilter<T> create(@NotNull @NotNull Class<T> type, @NotNull @NotNull Filter<? super T> filter)
      Creates and returns a class based type filter based on given filter instance.
      Type Parameters:
      T - Type of the filter.
      Parameters:
      type - The type to check for.
      filter - Used for filtering.
      Returns:
      The created type filter.
      Since:
      5.0.3
    • createExcludeFilter

      public static <T> TypedFilter<T> createExcludeFilter(@NotNull @NotNull Class<T> type, Class<? extends T>... excludes)
      Creates and returns a class based type filter with an additional exclude filtering of the specified sub classes.
      Type Parameters:
      T - Type of the filter.
      Parameters:
      type - The type to check for.
      excludes - A list of excluded classes.
      Returns:
      The created type filter.
      Since:
      4.2.416
    • createIncludeFilter

      public static <T> TypedFilter<T> createIncludeFilter(@NotNull @NotNull Class<T> type, Class<? extends T>... includes)
      Creates and returns a class based type filter with an additional include filtering of the specified sub classes.
      Type Parameters:
      T - Type of the filter.
      Parameters:
      type - The type to check basically for.
      includes - A list of included classes that should not be filtered.
      Returns:
      The created type filter.
      Since:
      5.0.3