de.caff.generics.matcher

## Class Match

- java.lang.Object
- - de.caff.generics.matcher.Match

-     public final class Match
      extends java.lang.Object

  Helper class for `matcher` construction.
  Author:
    Rammi

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static UniformMatcher<java.lang.Object>` | `DEFAULT_MATCHER` Basic matcher, using `Object.equals(Object)` method of first object.
    `static UniformMatcher<java.lang.Object>` | `REFERENCE_MATCHER` Matcher which is using reference equality, i.e. each object only matches with itself.
    `static UniformMatcher<java.lang.Object>` | `REVERTED_DEFAULT_MATCHER` Basic matcher, using `Object.equals(Object)` method of second object.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T extends java.lang.Comparable<T>> UniformMatcher<T>` | `forClass(java.lang.Class<T> type)` Create a matcher for a comparable type.
    `static <T> UniformMatcher<T>` | `from(java.util.Comparator<T> comparator)` Create a matcher from a comparator.
    `static <T1,T2> Matcher<T1,T2>` | `negate(Matcher<T1,T2> matcher)` Get a matcher which negates the result of a basic one.
    `static <T1,T2> Matcher<T1,T2>` | `revert(Matcher<T2,T1> matcher)` Get a reverted matcher from a basic one.
    `static <T1,T2> Matcher<T1,T2>` | `withNull(Matcher<T1,T2> matcher)` Get a matcher which enhances a given matcher which is not expecting `null` values with one which does.

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

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

- - ### Field Detail

    - #### DEFAULT_MATCHER

          public static final UniformMatcher<java.lang.Object> DEFAULT_MATCHER

      Basic matcher, using `Object.equals(Object)` method of first object. The value `null` is allowed and handled.

    - #### REVERTED_DEFAULT_MATCHER

          public static final UniformMatcher<java.lang.Object> REVERTED_DEFAULT_MATCHER

      Basic matcher, using `Object.equals(Object)` method of second object. The value `null` is allowed and handled.

    - #### REFERENCE_MATCHER

          public static final UniformMatcher<java.lang.Object> REFERENCE_MATCHER

      Matcher which is using reference equality, i.e. each object only matches with itself. The value `null` is allowed and handled.

  - ### Method Detail

    - #### revert

          public static <T1,T2> Matcher<T1,T2> revert(@NotNull
                                                      Matcher<T2,T1> matcher)

      Get a reverted matcher from a basic one.

      The reverted matcher compares two objects in the different direction. Basically equality should not depend on the direction, but in real life things are more complicated.

      Type Parameters:
        `T1` - type 1
        `T2` - type 2
      Parameters:
        `matcher` - basic matcher
      Returns:
        matcher with inverted comparison direction
      See Also:
        `RevertedMatcher`

    - #### negate

          public static <T1,T2> Matcher<T1,T2> negate(@NotNull
                                                      Matcher<T1,T2> matcher)

      Get a matcher which negates the result of a basic one.
      Type Parameters:
        `T1` - type 1
        `T2` - type 2
      Parameters:
        `matcher` - basic matcher
      Returns:
        matcher which returns `true` when the basic matcher returns `false` and vice versa
      See Also:
        `NegateMatcher`

    - #### withNull

          public static <T1,T2> Matcher<T1,T2> withNull(@NotNull
                                                        Matcher<T1,T2> matcher)

      Get a matcher which enhances a given matcher which is not expecting `null` values with one which does.
      Type Parameters:
        `T1` - type 1
        `T2` - type 2
      Parameters:
        `matcher` - basic matcher not handling `null` values
      Returns:
        matcher handling `null` values

    - #### from

          public static <T> UniformMatcher<T> from(@NotNull
                                                   java.util.Comparator<T> comparator)

      Create a matcher from a comparator. It will consider objects equal if the comparator compares them with a `0` result.
      Type Parameters:
        `T` - type
      Parameters:
        `comparator` - comparator
      Returns:
        matcher which uses the comparator for evaluating equality
      See Also:
        `ComparatorMatcher`

    - #### forClass

          public static <T extends java.lang.Comparable<T>> UniformMatcher<T> forClass(@NotNull
                                                                                       java.lang.Class<T> type)

      Create a matcher for a comparable type. It will consider objects equal if the compareTo() method of the first object compares them with a `0` result.
      Type Parameters:
        `T` - type
      Parameters:
        `type` - comparable type
      Returns:
        matcher using the compareTo() method
      See Also:
        `ComparableMatcher`