Class TransformAndCheckFunction<T>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.logic.TransformAndCheckFunction<T>
-
- Type Parameters:
T- type of input accepted by this function
@ThreadSafe public class TransformAndCheckFunction<T> extends Object implements Function<T,Optional<? extends T>>
AFunctionthat receives an input, runs it through a pre-processor and checks the result against a constraint. If the constraint matches that value is returned, wrapped in anOptional. If the constraint is not met andfailOnConstraintViolationis false thenOptional.empty()is returned. If the constraint is not met andfailOnConstraintViolationis true then anIllegalArgumentExceptionis thrown.
-
-
Field Summary
Fields Modifier and Type Field Description private Predicate<T>constraintA constraint which must be met in order for an input to be valid.private booleanfailOnConstraintViolationWhether input that does not meet the constraint should cause an error or just be silently dropped.private Function<T,? extends T>preprocessorA function applied to input prior to being constraint checked and accepted.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<? extends T>apply(T input)booleanequals(Object obj)inthashCode()StringtoString()
-
-
-
Field Detail
-
preprocessor
private final Function<T,? extends T> preprocessor
A function applied to input prior to being constraint checked and accepted.
-
constraint
private final Predicate<T> constraint
A constraint which must be met in order for an input to be valid.
-
failOnConstraintViolation
private final boolean failOnConstraintViolation
Whether input that does not meet the constraint should cause an error or just be silently dropped.
-
-
Constructor Detail
-
TransformAndCheckFunction
public TransformAndCheckFunction(@Nonnull Function<T,? extends T> inputPreprocessor, @Nonnull Predicate<T> inputConstraint, boolean failOnInputConstraintViolation)Constructor.- Parameters:
inputPreprocessor- function applied to input prior to being constraint checked and acceptedinputConstraint- constraint which must be met in order for an input to be validfailOnInputConstraintViolation- whether input that does not meet the constraint should cause an error or just be ignored
-
-