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 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.booleanequals(Object other)inthashCode()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(Function<T,V> mapper)Maps this instance to a Match of another type.booleanmatches(T other)Checks if this instance matches specified value.StringtoString()
-
-
-
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
-
-