Package io.atlassian.fugue
Class Pair<A,B>
java.lang.Object
io.atlassian.fugue.Pair<A,B>
- All Implemented Interfaces:
Serializable
Represents a pair of objects.
- Since:
- 1.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <A,B> Pair <B, B> Performs function application within an homogeneous pair (applicative functor pattern).<AA,BB> Pair <AA, BB> Applies functions to each of the left and right values to produce a new pair.boolean<R> Rfold(BiFunction<? super A, ? super B, R> f) Applies a function to left and right values to produce a single result.inthashCode()left()Accessor method for the left value of the pair.Applies a function to the left value to produce a new Pair.Function for accessing the left value ofpairs.static <A,B> Pair <B, B> Apply a function to both elements of an homogeneous pair.static <A,B> Pair <A, B> pair(A left, B right) Factory method for static Pair growth.static <A,B> BiFunction <A, B, Pair<A, B>> pairs()Factory method for a Pair factory function.right()Accessor method for the right value of the pair.qApplies a function to the right value to produce a new Pair.Function for accessing the right value ofpairs.swap()toString()Zips two iterables into a single iterable that producespairs.Zips the two given optionals into an optional of a pair.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
HALF_WORD
private static final int HALF_WORD- See Also:
-
left
-
right
-
-
Constructor Details
-
Pair
Constructor for Pair.- Parameters:
left- value, cannot be nullright- value, cannot be null
-
-
Method Details
-
pair
Factory method for static Pair growth.- Type Parameters:
A- the left value typeB- the right value type- Parameters:
left- value, cannot be nullright- value, cannot be null- Returns:
- the Pair containing the passed values
-
pairs
Factory method for a Pair factory function.- Type Parameters:
A- the left value typeB- the right value type- Returns:
- a function that constructs Pairs
-
leftValue
Function for accessing the left value ofpairs.- Type Parameters:
A- the left value type- Returns:
- a Function that given a
Pairreturns the left side value - Since:
- 1.1
-
rightValue
Function for accessing the right value ofpairs.- Type Parameters:
B- the right value type- Returns:
- a Function that given a
Pairreturns the right side value - Since:
- 1.1
-
ap
Performs function application within an homogeneous pair (applicative functor pattern).- Parameters:
aa- an homogeneous pairff- The pair of functions to apply.- Returns:
- A new pair after applying the given pair of functions through aa.
-
map
Apply a function to both elements of an homogeneous pair.- Parameters:
aa- an homogeneous pairf- function to apply to both elements of aa- Returns:
- A new pair after applying the function to aa elements.
-
zip
Zips two iterables into a single iterable that producespairs.- Type Parameters:
A- LHS typeB- RHS type- Parameters:
as- left valuesbs- right values- Returns:
- an
iterableof pairs, only as long as the shortest input iterable. - Since:
- 1.1
-
zip
Zips the two given optionals into an optional of a pair.- Type Parameters:
A- the first typeB- the second type- Parameters:
oA- the first optionaloB- the second optional- Returns:
- empty if either or both optionals are empty
- Since:
- 4.6.0
-
left
Accessor method for the left value of the pair.- Returns:
- a A object.
-
right
Accessor method for the right value of the pair.q- Returns:
- a B object.
-
swap
- Returns:
- a new Pair wth the left and right values swapped.
- Since:
- 6.1
-
fold
Applies a function to left and right values to produce a single result.- Type Parameters:
R- the result type- Parameters:
f- the function to apply to the values- Returns:
- the result of the applied function
- Since:
- 6.1
-
leftMap
Applies a function to the left value to produce a new Pair.- Type Parameters:
AA- The type of the new left value- Parameters:
fLeft- the function to be applied to the left value- Returns:
- A new Pair containing the new left value, and the existing right value
- Since:
- 6.1
-
rightMap
Applies a function to the right value to produce a new Pair.- Type Parameters:
BB- The type of the new right value- Parameters:
fRight- the function to be applied to the right value- Returns:
- A new Pair containing the existing left value, and the new right value
- Since:
- 6.1
-
bimap
public <AA,BB> Pair<AA,BB> bimap(Function<? super A, ? extends AA> fLeft, Function<? super B, ? extends BB> fRight) Applies functions to each of the left and right values to produce a new pair.- Type Parameters:
AA- the type of the new left valueBB- the type of the new right value- Parameters:
fLeft- the function to be applied to the left valuefRight- the function to be applied to the right value- Returns:
- a new Pair containing the new left and right values
- Since:
- 6.1
-
toString
-
equals
-
hashCode
public int hashCode()
-