Package org.rspeer.commons
Class Pair<L,R>
- java.lang.Object
-
- org.rspeer.commons.Pair<L,R>
-
public class Pair<L,R> extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
accumulate(BiFunction<L,R,T> function)
Pair<L,R>
filter(BiPredicate<L,R> predicate)
L
getLeft()
L
getLeft(L defaultValue)
R
getRight()
R
getRight(R defaultValue)
void
ifPresent(BiConsumer<L,R> consumer)
If neither element is null, applies the given consumer
-
-
-
Method Detail
-
getLeft
public L getLeft()
-
getRight
public R getRight()
-
accumulate
public <T> T accumulate(BiFunction<L,R,T> function)
-
filter
public Pair<L,R> filter(BiPredicate<L,R> predicate)
- Parameters:
predicate
- The predicate to test the elements- Returns:
- The pair if the predicate accepts it, else returns a Pair where the left and right elements are null
-
ifPresent
public void ifPresent(BiConsumer<L,R> consumer)
If neither element is null, applies the given consumer- Parameters:
consumer
- The operation to perform on the elements
-
-