Class Match<T>

java.lang.Object
io.atomix.utils.misc.Match<T>
Type Parameters:
T - type of value

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

    Fields
    Modifier and Type
    Field
    Description
    static final Match
     
    static final Match
     
    static final Match
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> Match<T>
    any()
    Returns a Match that matches any value including null.
    boolean
    equals(Object other)
     
    int
     
    static <T> Match<T>
    Returns a Match that matches all non-null values.
    static <T> Match<T>
    ifNotValue(T value)
    Returns a Match that matches any value except the specified value.
    static <T> Match<T>
    Returns a Match that matches null values.
    static <T> Match<T>
    ifValue(T value)
    Returns a Match that only matches the specified value.
    <V> Match<V>
    map(Function<T,V> mapper)
    Maps this instance to a Match of another type.
    boolean
    matches(T other)
    Checks if this instance matches specified value.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ANY

      public static final Match ANY
    • NULL

      public static final Match NULL
    • NOT_NULL

      public static final Match NOT_NULL
  • Method Details

    • 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
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object