Class BooleanMatcher<T>

Type Parameters:
T - The actual matched type of this matcher.
All Implemented Interfaces:
ElementMatcher<T>, ElementMatcher.Junction<T>

@Enhance public class BooleanMatcher<T> extends ElementMatcher.Junction.AbstractBase<T>
An element matcher that returns a fixed result.
  • Field Details

    • TRUE

      private static final BooleanMatcher<?> TRUE
      A matcher that always returns true.
    • FALSE

      private static final BooleanMatcher<?> FALSE
      A matcher that always returns false.
    • matches

      protected final boolean matches
      The predefined result.
  • Constructor Details

    • BooleanMatcher

      public BooleanMatcher(boolean matches)
      Creates a new boolean element matcher.
      Parameters:
      matches - The predefined result.
  • Method Details

    • of

      public static <T> ElementMatcher.Junction<T> of(boolean matches)
      Returns an element matcher that returns the provided result.
      Type Parameters:
      T - The type of the matched entity.
      Parameters:
      matches - A matcher that always matches or never matches.
      Returns:
      A matcher that returns the provided result for all inputs.
    • matches

      public boolean matches(@MaybeNull T target)
      Matches a target against this element matcher.
      Parameters:
      target - The instance to be matched or null.
      Returns:
      true if the given element is matched by this matcher or false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object