Class Match<T>

  • Type Parameters:
    T - type of value

    public final class Match<T>
    extends Object
    Utility class for checking matching values.
    • Field Detail

      • ANY

        public static final Match ANY
      • NULL

        public static final Match NULL
      • NOT_NULL

        public static final Match NOT_NULL
    • Method Detail

      • any

        public static <T> Match<T> any()
        Returns a Match that matches any value including null.
        Type Parameters:
        T - match type
        Returns:
        new instance
      • ifNull

        public static <T> Match<T> ifNull()
        Returns a Match that matches null values.
        Type Parameters:
        T - match type
        Returns:
        new instance
      • ifNotNull

        public static <T> Match<T> ifNotNull()
        Returns a Match that matches all non-null values.
        Type Parameters:
        T - match type
        Returns:
        new instance
      • ifValue

        public static <T> Match<T> ifValue​(T value)
        Returns a Match that only matches the specified value.
        Type Parameters:
        T - match type
        Parameters:
        value - value to match
        Returns:
        new instance
      • ifNotValue

        public static <T> Match<T> ifNotValue​(T value)
        Returns a Match that matches any value except the specified value.
        Type Parameters:
        T - match type
        Parameters:
        value - value to not match
        Returns:
        new instance
      • map

        public <V> Match<V> map​(Function<T,​V> mapper)
        Maps this instance to a Match of another type.
        Type Parameters:
        V - new match type
        Parameters:
        mapper - transformation function
        Returns:
        new instance
      • matches

        public boolean matches​(T other)
        Checks if this instance matches specified value.
        Parameters:
        other - other value
        Returns:
        true if matches; false otherwise
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object