Added destructuring support to pairs
This commit is contained in:
@@ -38,4 +38,26 @@ public class Pair<A, B> {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
/**
|
||||
* component1 exists to allow a pair to be destructured by kotlin.
|
||||
* The default kotlin pair already has this, however there is no default
|
||||
* pair in java so this exists for parity.
|
||||
*
|
||||
* @return First.
|
||||
*/
|
||||
public A component1() {
|
||||
return first;
|
||||
}
|
||||
|
||||
/**
|
||||
* component2 exists to allow a pair to be destructured by kotlin.
|
||||
* The default kotlin pair already has this, however there is no default
|
||||
* pair in java so this exists for parity.
|
||||
*
|
||||
* @return First.
|
||||
*/
|
||||
public B component2() {
|
||||
return second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,4 +34,15 @@ public class Triplet<A, B, C> extends Pair<A, B> {
|
||||
|
||||
this.third = third;
|
||||
}
|
||||
|
||||
/**
|
||||
* component3 exists to allow a pair to be destructured by kotlin.
|
||||
* The default kotlin pair already has this, however there is no default
|
||||
* pair in java so this exists for parity.
|
||||
*
|
||||
* @return First.
|
||||
*/
|
||||
public C component3() {
|
||||
return third;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user