Package org.silverpeas.core.util.filter
Class FilterByType
- java.lang.Object
-
- org.silverpeas.core.util.filter.FilterByType
-
public class FilterByType extends Object implements Filter<Class<?>,Object>
A filter by the type of the wrapped object. If the type of the object matches a given predicate then the operation with the matched predicate is performed against this object. The object cannot be null otherwise nothing is performed.- Author:
- mmoquillon
-
-
Constructor Summary
Constructors Constructor Description FilterByType(Object value)
Constructs a filter by type on the specified value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FilterByType
match(Predicate<Class<?>> predicate, Consumer<Object> operation)
Plays the specified predicate against an underlying object and applies the specified operation if and only if the predicate is true.<V> FilterMatcher<Class<?>,Object,V>
matchFirst(Predicate<Class<?>> predicate, Function<Object,V> function)
Plays the specified predicate against an underlying object and applies the specified function if and only if the predicate is true.
-
-
-
Method Detail
-
match
public FilterByType match(Predicate<Class<?>> predicate, Consumer<Object> operation)
Description copied from interface:Filter
Plays the specified predicate against an underlying object and applies the specified operation if and only if the predicate is true.
-
matchFirst
public <V> FilterMatcher<Class<?>,Object,V> matchFirst(Predicate<Class<?>> predicate, Function<Object,V> function)
Description copied from interface:Filter
Plays the specified predicate against an underlying object and applies the specified function if and only if the predicate is true. If the predicate is true, the result of the function is stored in order to be retrieved later and the chain of predicate to play is stopped; the next predicates won't be played and hence their associated functions won't be executed. The result of the function mustn't be null otherwise anAssertionError
is thrown.- Specified by:
matchFirst
in interfaceFilter<Class<?>,Object>
- Type Parameters:
V
- the return type of the function.- Parameters:
predicate
- the predicate to match.function
- the function associated with the predicate and that returns a non-null computation result.- Returns:
- a
FilterMatcher
instance from which the result can be retrieved and with which other filtering rules can be set.
-
-