Package com.landawn.abacus.util
Class Pair<L,R>
java.lang.Object
com.landawn.abacus.util.Pair<L,R>
- Type Parameters:
L
-R
-
- All Implemented Interfaces:
Mutable
- Since:
- 0.8
- Author:
- Haiyang Li
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<E extends Exception>
voidaccept
(Throwables.BiConsumer<? super L, ? super R, E> action) <E extends Exception>
voidaccept
(Throwables.Consumer<? super Pair<L, R>, E> action) copy()
static <K,
V> Pair<K, V> Create a newPair
with the values from the specifiedentry
.static <L,
R> Pair<L, R>[] boolean
<E extends Exception>
u.Optional<Pair<L,R>> filter
(Throwables.BiPredicate<? super L, ? super R, E> predicate) <E extends Exception>
u.Optional<Pair<L,R>> filter
(Throwables.Predicate<? super Pair<L, R>, E> predicate) <E extends Exception>
voidforEach
(Throwables.Consumer<?, E> comsumer) getAndSetLeft
(L newLeft) Gets the and set left.getAndSetRight
(R newRight) Gets the and set right.getLeft()
Gets the left.getRight()
Gets the right.int
hashCode()
<U,
E extends Exception>
Umap
(Throwables.BiFunction<? super L, ? super R, U, E> mapper) <U,
E extends Exception>
Umap
(Throwables.Function<? super Pair<L, R>, U, E> mapper) static <L,
R> Pair<L, R> of
(L l, R r) reverse()
Returns a new instance of Pair<R, L>.void
setAndGetLeft
(L newLeft) Sets the and get left.setAndGetRight
(R newRight) Sets the and get right.<E extends Exception>
booleansetIf
(L newLeft, R newRight, Throwables.TriPredicate<? super Pair<L, R>, ? super L, ? super R, E> predicate) Set to the specifiednewLeft
andnewRight
and returnstrue
ifpredicate
returns true.void
Sets the left.<E extends Exception>
booleanSet to the specifiednewLeft
and returnstrue
ifpredicate
returns true.void
Sets the right.<E extends Exception>
booleansetRightIf
(R newRight, Throwables.BiPredicate<? super Pair<L, R>, ? super R, E> predicate) Set to the specifiednewRight
and returnstrue
ifpredicate
returns true.stream()
Object[]
toArray()
<A> A[]
toArray
(A[] a) toEntry()
u.Optional<Pair<L,
R>> toString()
toTuple()
-
Field Details
-
left
-
right
-
-
Constructor Details
-
Pair
public Pair()
-
-
Method Details
-
of
- Type Parameters:
L
-R
-- Parameters:
l
-r
-- Returns:
-
create
Create a newPair
with the values from the specifiedentry
.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
entry
-- Returns:
-
emptyArray
- Type Parameters:
L
-R
-- Returns:
-
getLeft
Gets the left.- Returns:
-
setLeft
Sets the left.- Parameters:
left
- the new left
-
getRight
Gets the right.- Returns:
-
setRight
Sets the right.- Parameters:
right
- the new right
-
set
- Parameters:
left
-right
-
-
getAndSetLeft
Gets the and set left.- Parameters:
newLeft
-- Returns:
-
setAndGetLeft
Sets the and get left.- Parameters:
newLeft
-- Returns:
-
getAndSetRight
Gets the and set right.- Parameters:
newRight
-- Returns:
-
setAndGetRight
Sets the and get right.- Parameters:
newRight
-- Returns:
-
setLeftIf
public <E extends Exception> boolean setLeftIf(L newLeft, Throwables.BiPredicate<? super Pair<L, R>, throws E? super L, E> predicate) Set to the specifiednewLeft
and returnstrue
ifpredicate
returns true. Otherwise returnsfalse
without setting the value to new value.- Type Parameters:
E
-- Parameters:
newLeft
-predicate
- - the first parameter is current pair, the second parameter is thenewLeft
- Returns:
- Throws:
E
- the e
-
setRightIf
public <E extends Exception> boolean setRightIf(R newRight, Throwables.BiPredicate<? super Pair<L, R>, throws E? super R, E> predicate) Set to the specifiednewRight
and returnstrue
ifpredicate
returns true. Otherwise returnsfalse
without setting the value to new value.- Type Parameters:
E
-- Parameters:
newRight
-predicate
- - the first parameter is current pair, the second parameter is thenewRight
- Returns:
- Throws:
E
- the e
-
setIf
public <E extends Exception> boolean setIf(L newLeft, R newRight, Throwables.TriPredicate<? super Pair<L, R>, throws E? super L, ? super R, E> predicate) Set to the specifiednewLeft
andnewRight
and returnstrue
ifpredicate
returns true. Otherwise returnsfalse
without setting the left/right to new values.- Type Parameters:
E
-- Parameters:
newLeft
-newRight
-predicate
- - the first parameter is current pair, the second parameter is thenewLeft
, the third parameter is thenewRight
.- Returns:
- Throws:
E
- the e
-
reverse
Returns a new instance of Pair<R, L>.- Returns:
- a new instance of Pair<R, L>.
-
copy
- Returns:
-
toArray
- Returns:
-
toArray
public <A> A[] toArray(A[] a) - Type Parameters:
A
-- Parameters:
a
-- Returns:
-
forEach
- Type Parameters:
E
-- Parameters:
comsumer
-- Throws:
E
- the e
-
accept
public <E extends Exception> void accept(Throwables.BiConsumer<? super L, ? super R, throws EE> action) - Type Parameters:
E
-- Parameters:
action
-- Throws:
E
- the e
-
accept
- Type Parameters:
E
-- Parameters:
action
-- Throws:
E
- the e
-
map
public <U,E extends Exception> U map(Throwables.BiFunction<? super L, ? super R, throws EU, E> mapper) - Type Parameters:
U
-E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
map
- Type Parameters:
U
-E
-- Parameters:
mapper
-- Returns:
- Throws:
E
- the e
-
filter
public <E extends Exception> u.Optional<Pair<L,R>> filter(Throwables.BiPredicate<? super L, ? super R, throws EE> predicate) - Type Parameters:
E
-- Parameters:
predicate
-- Returns:
- Throws:
E
- the e
-
filter
public <E extends Exception> u.Optional<Pair<L,R>> filter(Throwables.Predicate<? super Pair<L, R>, throws EE> predicate) - Type Parameters:
E
-- Parameters:
predicate
-- Returns:
- Throws:
E
- the e
-
stream
- Returns:
-
stream
public <T,E extends Exception> Stream<T> stream(Throwables.Function<? super Pair<L, R>, throws EStream<T>, E> func) - Type Parameters:
T
-E
-- Parameters:
func
-- Returns:
- Throws:
E
-
toOptional
- Returns:
-
toTuple
- Returns:
-
toEntry
- Returns:
-
toImmutableEntry
- Returns:
-
hashCode
public int hashCode() -
equals
-
toString
-