aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/apache/commons/lang3/tuple
diff options
context:
space:
mode:
authorGary Gregory <garydgregory@gmail.com>2020-06-23 11:07:22 -0400
committerGary Gregory <garydgregory@gmail.com>2020-06-23 11:07:22 -0400
commit341aaa797d515a1fce5def6b41cdc481701ad389 (patch)
treec2f8f5eaefcf1941fbd9b9fcd45892835e60d938 /src/main/java/org/apache/commons/lang3/tuple
parent744da0e2555dd6439a6c95a927bf8a638ea83f95 (diff)
downloadapache-commons-lang-341aaa797d515a1fce5def6b41cdc481701ad389.tar.gz
Added ImmutablePair factory methods left() and right().
Diffstat (limited to 'src/main/java/org/apache/commons/lang3/tuple')
-rw-r--r--src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
index 9c106e630..e6d4b9255 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
@@ -70,6 +70,21 @@ public final class ImmutablePair<L, R> extends Pair<L, R> {
}
/**
+ * <p>Creates an immutable pair of two objects inferring the generic types.</p>
+ *
+ * <p>This factory allows the pair to be created using inference to
+ * obtain the generic types.</p>
+ *
+ * @param <L> the left element type
+ * @param left the left element, may be null
+ * @return a pair formed from the two parameters, not null
+ * @since 3.11
+ */
+ public static <L, R> Pair<L, R> left(final L left) {
+ return ImmutablePair.of(left, null);
+ }
+
+ /**
* Returns an immutable pair of nulls.
*
* @param <L> the left element of this pair. Value is {@code null}.
@@ -122,6 +137,21 @@ public final class ImmutablePair<L, R> extends Pair<L, R> {
return new ImmutablePair<>(left, right);
}
+ /**
+ * <p>Creates an immutable pair of two objects inferring the generic types.</p>
+ *
+ * <p>This factory allows the pair to be created using inference to
+ * obtain the generic types.</p>
+ *
+ * @param <R> the right element type
+ * @param right the right element, may be null
+ * @return a pair formed from the two parameters, not null
+ * @since 3.11
+ */
+ public static <L, R> Pair<L, R> right(final R right) {
+ return ImmutablePair.of(null, right);
+ }
+
/** Left object */
public final L left;