Package net.shibboleth.shared.logic

# Class TransformAndCheckFunction<T>

java.lang.Object
net.shibboleth.shared.logic.TransformAndCheckFunction<T>

Type Parameters:
  `T` - type of input accepted by this function

All Implemented Interfaces:
  `Function<T,Optional<? extends T>>`

@ThreadSafe public class TransformAndCheckFunction<T> extends Object implements Function<T,Optional<? extends T>>
A `Function` that 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 an `Optional`. If the constraint is not met and `failOnConstraintViolation` is false then `Optional.empty()` is returned. If the constraint is not met and `failOnConstraintViolation` is true then an `IllegalArgumentException` is thrown.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final Predicate<T>`
`constraint`
A constraint which must be met in order for an input to be valid.
`private final boolean`
`failOnConstraintViolation`
Whether input that does not meet the constraint should cause an error or just be silently dropped.
`private final Function<T,? extends T>`
`preprocessor`
A function applied to input prior to being constraint checked and accepted.

## Constructor Summary

Constructors
Constructor
Description
`TransformAndCheckFunction(Function<T,? extends T> inputPreprocessor, Predicate<T> inputConstraint, boolean failOnInputConstraintViolation)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Optional<? extends T>`
`apply(T input)`
`boolean`
`equals(Object obj)`
`int`
`hashCode()`
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.function.Function

`andThen, compose`

## Field Details

### preprocessor

@Nonnull private final Function<T,? extends T> preprocessor
A function applied to input prior to being constraint checked and accepted.

### constraint

@Nonnull 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 Details

### 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 accepted
  `inputConstraint` - constraint which must be met in order for an input to be valid
  `failOnInputConstraintViolation` - whether input that does not meet the constraint should cause an error or just be ignored

## Method Details

### apply

public Optional<? extends T> apply(T input)

Specified by:
  `apply` in interface `Function<T,Optional<? extends T>>`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`