public class Matcher<T,TResult>
extends java.lang.Object
Constructor and Description |
---|
Matcher()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addAction(Predicates.Predicate1<T> predicate,
Actions.Action1<T> action)
Adds a predicate and a function.
|
void |
addFunction(Predicates.Predicate1<T> predicate)
Adds a predicate and an identity function (F(x)=>x).
|
void |
addFunction(Predicates.Predicate1<T> predicate,
Functions.Function1<T,TResult> func)
Adds a predicate and a function.
|
TResult |
match(T input)
Returns the first match based on the given input.
|
void |
setDefaultAction(Actions.Action1<T> action)
Sets the action that generates a default result, if there are no matches.
|
void |
setDefaultFunction(Functions.Function1<T,TResult> func)
Sets the function that generates a default result, if there are no matches.
|
void |
setDefaultThrow(java.lang.Throwable e)
Convenience method for throwing a specified exception type and message, if there are no matches to the matcher's input
|
void |
setDefaultThrowDetailed(java.lang.Throwable e)
Convenience method for throwing a specified exception type and message, if there are no matches to the matcher's input, with the
input's toString() representation being appended to the exception message.
|
public void addFunction(Predicates.Predicate1<T> predicate, Functions.Function1<T,TResult> func)
java.lang.NullPointerException
- An argument is nullpublic void addFunction(Predicates.Predicate1<T> predicate)
java.lang.NullPointerException
- An argument is nullpublic void addAction(Predicates.Predicate1<T> predicate, Actions.Action1<T> action)
java.lang.NullPointerException
- An argument is nullpublic void setDefaultAction(Actions.Action1<T> action)
public void setDefaultFunction(Functions.Function1<T,TResult> func)
public void setDefaultThrow(java.lang.Throwable e)
java.lang.NullPointerException
- An argument is nullpublic void setDefaultThrowDetailed(java.lang.Throwable e)
java.lang.NullPointerException
- An argument is nullpublic TResult match(T input)
java.lang.Throwable
- One of the predicates or actions may throw an exception