Package software.amazon.smithy.utils
Class Pair<L,R>
- java.lang.Object
-
- software.amazon.smithy.utils.Pair<L,R>
-
- Type Parameters:
L- Left value type.R- Right value type.
- All Implemented Interfaces:
java.util.Map.Entry<L,R>
public final class Pair<L,R> extends java.lang.Object implements java.util.Map.Entry<L,R>Generic immutable pair of values.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)static <L,R>
java.util.stream.Stream<Pair<L,R>>flatMapStream(L left, java.util.function.Function<L,java.util.Optional<R>> f)Creates aStreamof zero or one Pairs if the mapping function returns a non-emptyOptional.static <L,R>
java.util.stream.Stream<Pair<L,R>>flatMapStream(L left, java.util.function.Supplier<java.util.Optional<R>> f)LgetKey()LgetLeft()RgetRight()RgetValue()inthashCode()static <L,R>
Pair<L,R>of(L left, R right)Creates a Pair from the given values.RsetValue(R value)java.lang.StringtoString()
-
-
-
Method Detail
-
of
public static <L,R> Pair<L,R> of(L left, R right)
Creates a Pair from the given values.- Type Parameters:
L- Left value type.R- Right value type.- Parameters:
left- Left value.right- Right value.- Returns:
- Returns the created Pair.
-
flatMapStream
public static <L,R> java.util.stream.Stream<Pair<L,R>> flatMapStream(L left, java.util.function.Function<L,java.util.Optional<R>> f)
Creates aStreamof zero or one Pairs if the mapping function returns a non-emptyOptional.- Type Parameters:
L- Left value type.R- Right value type.- Parameters:
left- Value to set as the left side of the pair.f- Mapping function that accepts the left value and returns an Optional value.- Returns:
- Returns a Stream that contains either a single Pair if the Optional is not empty, or an empty Stream.
-
flatMapStream
public static <L,R> java.util.stream.Stream<Pair<L,R>> flatMapStream(L left, java.util.function.Supplier<java.util.Optional<R>> f)
-
getLeft
public L getLeft()
-
getRight
public R getRight()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
-
-