Package net.shibboleth.shared.logic

# Class PredicateDrivenFunction<T,U>

java.lang.Object
net.shibboleth.shared.logic.PredicateDrivenFunction<T,U>

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

All Implemented Interfaces:
  `Function<T,U>`

@ThreadSafe public class PredicateDrivenFunction<T,U> extends Object implements Function<T,U>
A `Function` that runs a `Predicate` and then runs one of two other possible functions based on the result.

If either function is null, the result will be null if that function were needed.

Since:
  8.2.0

## Field Summary

Fields
Modifier and Type
Field
Description
`private final Function<? super T,U>`
`falseFunction`
Function to apply if predicate is false.
`private final Predicate<? super T>`
`predicate`
A predicate to apply.
`private final Function<? super T,U>`
`trueFunction`
Function to apply if predicate is true.

## Constructor Summary

Constructors
Constructor
Description
`PredicateDrivenFunction(Predicate<? super T> condition, Function<? super T,U> whenTrue, Function<? super T,U> whenFalse)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`U`
`apply(T input)`

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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

`andThen, compose`

## Field Details

### predicate

@Nonnull private final Predicate<? super T> predicate
A predicate to apply.

### trueFunction

@Nonnull private final Function<? super T,U> trueFunction
Function to apply if predicate is true.

### falseFunction

@Nonnull private final Function<? super T,U> falseFunction
Function to apply if predicate is false.

## Constructor Details

### PredicateDrivenFunction

public PredicateDrivenFunction(@Nonnull @ParameterName(name="condition") Predicate<? super T> condition, @Nullable @ParameterName(name="whenTrue") Function<? super T,U> whenTrue, @Nullable @ParameterName(name="whenFalse") Function<? super T,U> whenFalse)
Constructor.

Parameters:
  `condition` - predicate to apply
  `whenTrue` - function to apply if predicate evaluates to true
  `whenFalse` - function to apply if predicate evaluates to false

## Method Details

### apply

public U apply(@Nullable T input)

Specified by:
  `apply` in interface `Function<T,U>`