From ffb8b29790cf781765fed9d1da6ec6988842ad18 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 10 May 2019 09:11:02 -0400 Subject: [PATCH] Sort methods. --- .../commons/lang3/tuple/ImmutablePair.java | 30 +++--- .../commons/lang3/tuple/ImmutableTriple.java | 34 +++---- .../commons/lang3/tuple/MutablePair.java | 32 +++---- .../commons/lang3/tuple/MutableTriple.java | 50 +++++----- .../org/apache/commons/lang3/tuple/Pair.java | 96 +++++++++---------- .../apache/commons/lang3/tuple/Triple.java | 50 +++++----- 6 files changed, 146 insertions(+), 146 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 e494e12b6..488fd7cb5 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java @@ -43,6 +43,16 @@ public final class ImmutablePair extends Pair { */ public static final ImmutablePair[] EMPTY_ARRAY = new ImmutablePair[0]; + /** + * An immutable pair of nulls. + */ + // This is not defined with generics to avoid warnings in call sites. + @SuppressWarnings("rawtypes") + private static final ImmutablePair NULL = of(null, null); + + /** Serialization version */ + private static final long serialVersionUID = 4954918890077093841L; + /** * Returns the empty array singleton that can be assigned without compiler warning. * @@ -57,16 +67,6 @@ public static ImmutablePair[] emptyArray() { return (ImmutablePair[]) EMPTY_ARRAY; } - /** - * An immutable pair of nulls. - */ - // This is not defined with generics to avoid warnings in call sites. - @SuppressWarnings("rawtypes") - private static final ImmutablePair NULL = of(null, null); - - /** Serialization version */ - private static final long serialVersionUID = 4954918890077093841L; - /** * Returns an immutable pair of nulls. * @@ -79,11 +79,6 @@ public static ImmutablePair nullPair() { return NULL; } - /** Left object */ - public final L left; - /** Right object */ - public final R right; - /** *

Obtains an immutable pair of two objects inferring the generic types.

* @@ -99,6 +94,11 @@ public static ImmutablePair nullPair() { public static ImmutablePair of(final L left, final R right) { return new ImmutablePair<>(left, right); } + /** Left object */ + public final L left; + + /** Right object */ + public final R right; /** * Create a new pair instance. diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java index 2588f6afa..f51df4589 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java +++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java @@ -44,6 +44,16 @@ public final class ImmutableTriple extends Triple { */ public static final ImmutableTriple[] EMPTY_ARRAY = new ImmutableTriple[0]; + /** + * An immutable triple of nulls. + */ + // This is not defined with generics to avoid warnings in call sites. + @SuppressWarnings("rawtypes") + private static final ImmutableTriple NULL = of(null, null, null); + + /** Serialization version */ + private static final long serialVersionUID = 1L; + /** * Returns the empty array singleton that can be assigned without compiler warning. * @@ -59,16 +69,6 @@ public static ImmutableTriple[] emptyArray() { return (ImmutableTriple[]) EMPTY_ARRAY; } - /** - * An immutable triple of nulls. - */ - // This is not defined with generics to avoid warnings in call sites. - @SuppressWarnings("rawtypes") - private static final ImmutableTriple NULL = of(null, null, null); - - /** Serialization version */ - private static final long serialVersionUID = 1L; - /** * Returns an immutable triple of nulls. * @@ -82,13 +82,6 @@ public static ImmutableTriple nullTriple() { return NULL; } - /** Left object */ - public final L left; - /** Middle object */ - public final M middle; - /** Right object */ - public final R right; - /** *

Obtains an immutable triple of three objects inferring the generic types.

* @@ -106,6 +99,13 @@ public static ImmutableTriple nullTriple() { public static ImmutableTriple of(final L left, final M middle, final R right) { return new ImmutableTriple<>(left, middle, right); } + /** Left object */ + public final L left; + /** Middle object */ + public final M middle; + + /** Right object */ + public final R right; /** * Create a new triple instance. diff --git a/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java index a4800713a..58a66a725 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java @@ -38,6 +38,9 @@ public class MutablePair extends Pair { */ public static final MutablePair[] EMPTY_ARRAY = new MutablePair[0]; + /** Serialization version */ + private static final long serialVersionUID = 4954918890077093841L; + /** * Returns the empty array singleton that can be assigned without compiler warning. * @@ -52,14 +55,6 @@ public static MutablePair[] emptyArray() { return (MutablePair[]) EMPTY_ARRAY; } - /** Serialization version */ - private static final long serialVersionUID = 4954918890077093841L; - - /** Left object */ - public L left; - /** Right object */ - public R right; - /** *

Obtains a mutable pair of two objects inferring the generic types.

* @@ -75,6 +70,11 @@ public static MutablePair[] emptyArray() { public static MutablePair of(final L left, final R right) { return new MutablePair<>(left, right); } + /** Left object */ + public L left; + + /** Right object */ + public R right; /** * Create a new pair instance of two nulls. @@ -104,6 +104,14 @@ public L getLeft() { return left; } + /** + * {@inheritDoc} + */ + @Override + public R getRight() { + return right; + } + /** * Sets the left element of the pair. * @@ -113,14 +121,6 @@ public void setLeft(final L left) { this.left = left; } - /** - * {@inheritDoc} - */ - @Override - public R getRight() { - return right; - } - /** * Sets the right element of the pair. * diff --git a/src/main/java/org/apache/commons/lang3/tuple/MutableTriple.java b/src/main/java/org/apache/commons/lang3/tuple/MutableTriple.java index 4cf9474c5..b3352ac8c 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/MutableTriple.java +++ b/src/main/java/org/apache/commons/lang3/tuple/MutableTriple.java @@ -39,6 +39,9 @@ public class MutableTriple extends Triple { */ public static final MutableTriple[] EMPTY_ARRAY = new MutableTriple[0]; + /** Serialization version */ + private static final long serialVersionUID = 1L; + /** * Returns the empty array singleton that can be assigned without compiler warning. * @@ -54,16 +57,6 @@ public static MutableTriple[] emptyArray() { return (MutableTriple[]) EMPTY_ARRAY; } - /** Serialization version */ - private static final long serialVersionUID = 1L; - - /** Left object */ - public L left; - /** Middle object */ - public M middle; - /** Right object */ - public R right; - /** *

Obtains a mutable triple of three objects inferring the generic types.

* @@ -81,6 +74,13 @@ public static MutableTriple[] emptyArray() { public static MutableTriple of(final L left, final M middle, final R right) { return new MutableTriple<>(left, middle, right); } + /** Left object */ + public L left; + /** Middle object */ + public M middle; + + /** Right object */ + public R right; /** * Create a new triple instance of three nulls. @@ -113,20 +113,28 @@ public L getLeft() { } /** - * Sets the left element of the triple. - * - * @param left the new value of the left element, may be null + * {@inheritDoc} */ - public void setLeft(final L left) { - this.left = left; + @Override + public M getMiddle() { + return middle; } /** * {@inheritDoc} */ @Override - public M getMiddle() { - return middle; + public R getRight() { + return right; + } + + /** + * Sets the left element of the triple. + * + * @param left the new value of the left element, may be null + */ + public void setLeft(final L left) { + this.left = left; } /** @@ -138,14 +146,6 @@ public void setMiddle(final M middle) { this.middle = middle; } - /** - * {@inheritDoc} - */ - @Override - public R getRight() { - return right; - } - /** * Sets the right element of the triple. * diff --git a/src/main/java/org/apache/commons/lang3/tuple/Pair.java b/src/main/java/org/apache/commons/lang3/tuple/Pair.java index 1a25f1739..b64af80fc 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/Pair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/Pair.java @@ -40,9 +40,6 @@ */ public abstract class Pair implements Map.Entry, Comparable>, Serializable { - /** Serialization version */ - private static final long serialVersionUID = 4954918890077093841L; - private static final class PairAdapter extends Pair { private static final long serialVersionUID = 1L; @@ -64,6 +61,9 @@ public R setValue(R value) { } + /** Serialization version */ + private static final long serialVersionUID = 4954918890077093841L; + /** * An empty array. *

@@ -104,51 +104,6 @@ public static Pair of(final L left, final R right) { return new ImmutablePair<>(left, right); } - //----------------------------------------------------------------------- - /** - *

Gets the left element from this pair.

- * - *

When treated as a key-value pair, this is the key.

- * - * @return the left element, may be null - */ - public abstract L getLeft(); - - /** - *

Gets the right element from this pair.

- * - *

When treated as a key-value pair, this is the value.

- * - * @return the right element, may be null - */ - public abstract R getRight(); - - /** - *

Gets the key from this pair.

- * - *

This method implements the {@code Map.Entry} interface returning the - * left element as the key.

- * - * @return the left element as the key, may be null - */ - @Override - public final L getKey() { - return getLeft(); - } - - /** - *

Gets the value from this pair.

- * - *

This method implements the {@code Map.Entry} interface returning the - * right element as the value.

- * - * @return the right element as the value, may be null - */ - @Override - public R getValue() { - return getRight(); - } - //----------------------------------------------------------------------- /** *

Compares the pair based on the left element followed by the right element. @@ -182,6 +137,51 @@ public boolean equals(final Object obj) { return false; } + /** + *

Gets the key from this pair.

+ * + *

This method implements the {@code Map.Entry} interface returning the + * left element as the key.

+ * + * @return the left element as the key, may be null + */ + @Override + public final L getKey() { + return getLeft(); + } + + //----------------------------------------------------------------------- + /** + *

Gets the left element from this pair.

+ * + *

When treated as a key-value pair, this is the key.

+ * + * @return the left element, may be null + */ + public abstract L getLeft(); + + /** + *

Gets the right element from this pair.

+ * + *

When treated as a key-value pair, this is the value.

+ * + * @return the right element, may be null + */ + public abstract R getRight(); + + /** + *

Gets the value from this pair.

+ * + *

This method implements the {@code Map.Entry} interface returning the + * right element as the value.

+ * + * @return the right element as the value, may be null + */ + @Override + public R getValue() { + return getRight(); + } + /** *

Returns a suitable hash code. * The hash code follows the definition in {@code Map.Entry}.

diff --git a/src/main/java/org/apache/commons/lang3/tuple/Triple.java b/src/main/java/org/apache/commons/lang3/tuple/Triple.java index f99f24636..c52fd67bd 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/Triple.java +++ b/src/main/java/org/apache/commons/lang3/tuple/Triple.java @@ -39,9 +39,6 @@ */ public abstract class Triple implements Comparable>, Serializable { - /** Serialization version */ - private static final long serialVersionUID = 1L; - private static final class TripleAdapter extends Triple { private static final long serialVersionUID = 1L; @@ -63,6 +60,9 @@ public R getRight() { } + /** Serialization version */ + private static final long serialVersionUID = 1L; + /** * An empty array. *

@@ -106,28 +106,6 @@ public static Triple of(final L left, final M middle, final R return new ImmutableTriple<>(left, middle, right); } - //----------------------------------------------------------------------- - /** - *

Gets the left element from this triple.

- * - * @return the left element, may be null - */ - public abstract L getLeft(); - - /** - *

Gets the middle element from this triple.

- * - * @return the middle element, may be null - */ - public abstract M getMiddle(); - - /** - *

Gets the right element from this triple.

- * - * @return the right element, may be null - */ - public abstract R getRight(); - //----------------------------------------------------------------------- /** *

Compares the triple based on the left element, followed by the middle element, @@ -164,6 +142,28 @@ public boolean equals(final Object obj) { return false; } + //----------------------------------------------------------------------- + /** + *

Gets the left element from this triple.

+ * + * @return the left element, may be null + */ + public abstract L getLeft(); + + /** + *

Gets the middle element from this triple.

+ * + * @return the middle element, may be null + */ + public abstract M getMiddle(); + + /** + *

Gets the right element from this triple.

+ * + * @return the right element, may be null + */ + public abstract R getRight(); + /** *

Returns a suitable hash code.

*