L
- R
- public final class Pair<L,R> extends Object
Constructor and Description |
---|
Pair()
Instantiates a new pair.
|
Modifier and Type | Method and Description |
---|---|
<E extends Exception> |
accept(Throwables.BiConsumer<? super L,? super R,E> action) |
<E extends Exception> |
accept(Throwables.Consumer<? super Pair<L,R>,E> action) |
Pair<L,R> |
copy() |
boolean |
equals(Object obj) |
<E extends Exception> |
filter(Throwables.BiPredicate<? super L,? super R,E> predicate) |
<E extends Exception> |
filter(Throwables.Predicate<? super Pair<L,R>,E> predicate) |
<E extends Exception> |
forEach(Throwables.Consumer<?,E> comsumer) |
static <K,V> Pair<K,V> |
from(Map.Entry<K,V> entry) |
L |
getAndSetLeft(L newLeft)
Gets the and set left.
|
R |
getAndSetRight(R newRight)
Gets the and set right.
|
L |
getLeft()
Gets the left.
|
R |
getRight()
Gets the right.
|
int |
hashCode() |
<U,E extends Exception> |
map(Throwables.BiFunction<? super L,? super R,U,E> mapper) |
<U,E extends Exception> |
map(Throwables.Function<? super Pair<L,R>,U,E> mapper) |
static <L,R> Pair<L,R> |
of(L l,
R r) |
Pair<R,L> |
reverse()
Returns a new instance of Pair<R, L>.
|
void |
set(L left,
R right) |
L |
setAndGetLeft(L newLeft)
Sets the and get left.
|
R |
setAndGetRight(R newRight)
Sets the and get right.
|
<E extends Exception> |
setIf(L newLeft,
R newRight,
Throwables.TriPredicate<? super Pair<L,R>,? super L,? super R,E> predicate)
Set to the specified
newLeft and newRight and returns true
if predicate returns true. |
void |
setLeft(L left)
Sets the left.
|
<E extends Exception> |
setLeftIf(L newLeft,
Throwables.BiPredicate<? super Pair<L,R>,? super L,E> predicate)
Set to the specified
newLeft and returns true
if predicate returns true. |
void |
setRight(R right)
Sets the right.
|
<E extends Exception> |
setRightIf(R newRight,
Throwables.BiPredicate<? super Pair<L,R>,? super R,E> predicate)
Set to the specified
newRight and returns true
if predicate returns true. |
Stream<Pair<L,R>> |
stream() |
<T,E extends Exception> |
stream(Throwables.Function<? super Pair<L,R>,Stream<T>,E> func) |
Object[] |
toArray() |
<A> A[] |
toArray(A[] a) |
Map.Entry<L,R> |
toEntry() |
u.Optional<Pair<L,R>> |
toOptional() |
String |
toString() |
Tuple.Tuple2<L,R> |
toTuple() |
public static <L,R> Pair<L,R> of(L l, R r)
L
- R
- l
- r
- public static <K,V> Pair<K,V> from(Map.Entry<K,V> entry)
K
- the key typeV
- the value typeentry
- public L getLeft()
public void setLeft(L left)
left
- the new leftpublic R getRight()
public void setRight(R right)
right
- the new rightpublic L getAndSetLeft(L newLeft)
newLeft
- public L setAndGetLeft(L newLeft)
newLeft
- public R getAndSetRight(R newRight)
newRight
- public R setAndGetRight(R newRight)
newRight
- public <E extends Exception> boolean setLeftIf(L newLeft, Throwables.BiPredicate<? super Pair<L,R>,? super L,E> predicate) throws E extends Exception
newLeft
and returns true
if predicate
returns true. Otherwise returns
false
without setting the value to new value.E
- newLeft
- predicate
- - the first parameter is current pair, the second
parameter is the newLeft
E
- the eE extends Exception
public <E extends Exception> boolean setRightIf(R newRight, Throwables.BiPredicate<? super Pair<L,R>,? super R,E> predicate) throws E extends Exception
newRight
and returns true
if predicate
returns true. Otherwise returns
false
without setting the value to new value.E
- newRight
- predicate
- - the first parameter is current pair, the second
parameter is the newRight
E
- the eE extends Exception
public <E extends Exception> boolean setIf(L newLeft, R newRight, Throwables.TriPredicate<? super Pair<L,R>,? super L,? super R,E> predicate) throws E extends Exception
newLeft
and newRight
and returns true
if predicate
returns true. Otherwise returns
false
without setting the left/right to new values.E
- newLeft
- newRight
- predicate
- - the first parameter is current pair, the second
parameter is the newLeft
, the third parameter is the newRight
.E
- the eE extends Exception
@Beta public Pair<R,L> reverse()
public Object[] toArray()
public <A> A[] toArray(A[] a)
A
- a
- public <E extends Exception> void forEach(Throwables.Consumer<?,E> comsumer) throws E extends Exception
E
- comsumer
- E
- the eE extends Exception
public <E extends Exception> void accept(Throwables.BiConsumer<? super L,? super R,E> action) throws E extends Exception
E
- action
- E
- the eE extends Exception
public <E extends Exception> void accept(Throwables.Consumer<? super Pair<L,R>,E> action) throws E extends Exception
E
- action
- E
- the eE extends Exception
public <U,E extends Exception> U map(Throwables.BiFunction<? super L,? super R,U,E> mapper) throws E extends Exception
U
- E
- mapper
- E
- the eE extends Exception
public <U,E extends Exception> U map(Throwables.Function<? super Pair<L,R>,U,E> mapper) throws E extends Exception
U
- E
- mapper
- E
- the eE extends Exception
public <E extends Exception> u.Optional<Pair<L,R>> filter(Throwables.BiPredicate<? super L,? super R,E> predicate) throws E extends Exception
E
- predicate
- E
- the eE extends Exception
public <E extends Exception> u.Optional<Pair<L,R>> filter(Throwables.Predicate<? super Pair<L,R>,E> predicate) throws E extends Exception
E
- predicate
- E
- the eE extends Exception
public <T,E extends Exception> Stream<T> stream(Throwables.Function<? super Pair<L,R>,Stream<T>,E> func) throws E extends Exception
E extends Exception
public u.Optional<Pair<L,R>> toOptional()
public Tuple.Tuple2<L,R> toTuple()
public boolean equals(Object obj)
Copyright © 2020. All rights reserved.