Class Visitor
java.lang.Object
fj.function.Visitor
The essence of the visitor design pattern expressed polymorphically.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassociation(List<P2<A, B>> x, Equal<A> eq) Uses an association list to perform a lookup with equality and returns a function that can be applied to a default, followed by the associated key to return a value.associationLazy(List<P2<A, B>> x, Equal<A> eq) Uses an association list to perform a lookup with equality and returns a function that can be applied to a default, followed by the associated key to return a value.static <X> XReturns the first value available in the given list of optional values.static <X> XnullablefindFirst(List<X> values, F0<X> def) Returns the first non-nullvalue in the given list of optional values.static <A,B> B nullableVisitor(List<F<A, B>> visitors, F0<B> def, A value) Returns the first non-nullvalue found in the list of visitors after application of the given value, otherwise returns the given default.static <A,B> B Returns the first value found in the list of visitors after application of the given value, otherwise returns the given default.
-
Constructor Details
-
Visitor
private Visitor()
-
-
Method Details
-
findFirst
Returns the first value available in the given list of optional values. If none is found return the given default value.- Parameters:
values- The optional values to search.def- The default value if no value is found in the list.- Returns:
- The first value available in the given list of optional values. If none is found return the given default value.
-
nullablefindFirst
Returns the first non-nullvalue in the given list of optional values. If none is found return the given default value.- Parameters:
values- The potentiallynullvalues to search.def- The default value if no value is found in the list.- Returns:
- The first non-
nullvalue in the given list of optional values. If none is found return the given default value.
-
visitor
Returns the first value found in the list of visitors after application of the given value, otherwise returns the given default.- Parameters:
visitors- The list of visitors to apply.def- The default if none of the visitors yield a value.value- The value to apply to the visitors.- Returns:
- The first value found in the list of visitors after application of the given value, otherwise returns the given default.
-
nullableVisitor
Returns the first non-nullvalue found in the list of visitors after application of the given value, otherwise returns the given default.- Parameters:
visitors- The list of visitors to apply looking for a non-null.def- The default if none of the visitors yield a non-nullvalue.value- The value to apply to the visitors.- Returns:
- The first value found in the list of visitors after application of the given value, otherwise returns the given default.
-
association
Uses an association list to perform a lookup with equality and returns a function that can be applied to a default, followed by the associated key to return a value.- Parameters:
x- The association list.eq- The equality for the association list keys.- Returns:
- A function that can be applied to a default value (there is no association) and an associated key.
-
associationLazy
Uses an association list to perform a lookup with equality and returns a function that can be applied to a default, followed by the associated key to return a value.- Parameters:
x- The association list.eq- The equality for the association list keys.- Returns:
- A function that can be applied to a default value (there is no association) and an associated key.
-