Package org.onlab.util
Class Match<T>
- java.lang.Object
-
- org.onlab.util.Match<T>
-
- Type Parameters:
T
- type of value
public final class Match<T> extends java.lang.Object
Utility class for checking matching values.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Match<T>
any()
Returns a Match that matches any value including null.boolean
equals(java.lang.Object other)
int
hashCode()
static <T> Match<T>
ifNotNull()
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>
ifNull()
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(java.util.function.Function<T,V> mapper)
Maps this instance to a Match of another type.boolean
matches(T other)
Checks if this instance matches specified value.java.lang.String
toString()
-
-
-
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(java.util.function.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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-