Rename getRightElement() to getRight(). Rename getLeftElement() to getLeft().
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1091241 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
54de75b635
commit
a7530eae97
|
@ -75,7 +75,7 @@ public class ImmutablePair<L, R> extends Pair<L, R> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public L getLeftElement() {
|
||||
public L getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class ImmutablePair<L, R> extends Pair<L, R> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public R getRightElement() {
|
||||
public R getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class MutablePair<L, R> extends Pair<L, R> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public L getLeftElement() {
|
||||
public L getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class MutablePair<L, R> extends Pair<L, R> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public R getRightElement() {
|
||||
public R getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class MutablePair<L, R> extends Pair<L, R> {
|
|||
* @return the old value for the right element
|
||||
*/
|
||||
public R setValue(R value) {
|
||||
R result = getRightElement();
|
||||
R result = getRight();
|
||||
setRightElement(value);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
|
|||
*
|
||||
* @return the left element, may be null
|
||||
*/
|
||||
public abstract L getLeftElement();
|
||||
public abstract L getLeft();
|
||||
|
||||
/**
|
||||
* <p>Gets the right element from this pair.</p>
|
||||
|
@ -79,7 +79,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
|
|||
*
|
||||
* @return the right element, may be null
|
||||
*/
|
||||
public abstract R getRightElement();
|
||||
public abstract R getRight();
|
||||
|
||||
/**
|
||||
* <p>Gets the key from this pair.</p>
|
||||
|
@ -90,7 +90,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
|
|||
* @return the left element as the key, may be null
|
||||
*/
|
||||
public final L getKey() {
|
||||
return getLeftElement();
|
||||
return getLeft();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +102,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
|
|||
* @return the right element as the value, may be null
|
||||
*/
|
||||
public R getValue() {
|
||||
return getRightElement();
|
||||
return getRight();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -114,8 +114,8 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
|
|||
* @return negative if this is less, zero if equal, positive if greater
|
||||
*/
|
||||
public int compareTo(Pair<L, R> other) {
|
||||
return new CompareToBuilder().append(getLeftElement(), other.getLeftElement())
|
||||
.append(getRightElement(), other.getRightElement()).toComparison();
|
||||
return new CompareToBuilder().append(getLeft(), other.getLeft())
|
||||
.append(getRight(), other.getRight()).toComparison();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,6 +174,6 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
|
|||
* @return a string for this object
|
||||
*/
|
||||
public String toString(String format) {
|
||||
return String.format(format, getClass().getSimpleName(), getLeftElement(), getRightElement());
|
||||
return String.format(format, getClass().getSimpleName(), getLeft(), getRight());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class EqualsBuilder implements Builder<Boolean> {
|
|||
static boolean isRegistered(Object lhs, Object rhs) {
|
||||
Set<Pair<IDKey, IDKey>> registry = getRegistry();
|
||||
Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);
|
||||
Pair<IDKey, IDKey> swappedPair = Pair.of(pair.getLeftElement(), pair.getRightElement());
|
||||
Pair<IDKey, IDKey> swappedPair = Pair.of(pair.getLeft(), pair.getRight());
|
||||
|
||||
return registry != null
|
||||
&& (registry.contains(pair) || registry.contains(swappedPair));
|
||||
|
|
|
@ -38,28 +38,28 @@ public class ImmutablePairTest {
|
|||
public void testBasic() throws Exception {
|
||||
ImmutablePair<Integer, String> pair = new ImmutablePair<Integer, String>(0, "foo");
|
||||
assertEquals(0, pair.left.intValue());
|
||||
assertEquals(0, pair.getLeftElement().intValue());
|
||||
assertEquals(0, pair.getLeft().intValue());
|
||||
assertEquals("foo", pair.right);
|
||||
assertEquals("foo", pair.getRightElement());
|
||||
assertEquals("foo", pair.getRight());
|
||||
ImmutablePair<Object, String> pair2 = new ImmutablePair<Object, String>(null, "bar");
|
||||
assertNull(pair2.left);
|
||||
assertNull(pair2.getLeftElement());
|
||||
assertNull(pair2.getLeft());
|
||||
assertEquals("bar", pair2.right);
|
||||
assertEquals("bar", pair2.getRightElement());
|
||||
assertEquals("bar", pair2.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPairOf() throws Exception {
|
||||
ImmutablePair<Integer, String> pair = ImmutablePair.of(0, "foo");
|
||||
assertEquals(0, pair.left.intValue());
|
||||
assertEquals(0, pair.getLeftElement().intValue());
|
||||
assertEquals(0, pair.getLeft().intValue());
|
||||
assertEquals("foo", pair.right);
|
||||
assertEquals("foo", pair.getRightElement());
|
||||
assertEquals("foo", pair.getRight());
|
||||
ImmutablePair<Object, String> pair2 = ImmutablePair.of(null, "bar");
|
||||
assertNull(pair2.left);
|
||||
assertNull(pair2.getLeftElement());
|
||||
assertNull(pair2.getLeft());
|
||||
assertEquals("bar", pair2.right);
|
||||
assertEquals("bar", pair2.getRightElement());
|
||||
assertEquals("bar", pair2.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -37,18 +37,18 @@ public class MutablePairTest {
|
|||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
|
||||
assertEquals(0, pair.getLeftElement().intValue());
|
||||
assertEquals("foo", pair.getRightElement());
|
||||
assertEquals(0, pair.getLeft().intValue());
|
||||
assertEquals("foo", pair.getRight());
|
||||
MutablePair<Object, String> pair2 = new MutablePair<Object, String>(null, "bar");
|
||||
assertNull(pair2.getLeftElement());
|
||||
assertEquals("bar", pair2.getRightElement());
|
||||
assertNull(pair2.getLeft());
|
||||
assertEquals("bar", pair2.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() throws Exception {
|
||||
MutablePair<Integer, String> pair = new MutablePair<Integer, String>();
|
||||
assertNull(pair.getLeftElement());
|
||||
assertNull(pair.getRightElement());
|
||||
assertNull(pair.getLeft());
|
||||
assertNull(pair.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,18 +56,18 @@ public class MutablePairTest {
|
|||
MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo");
|
||||
pair.setLeftElement(42);
|
||||
pair.setRightElement("bar");
|
||||
assertEquals(42, pair.getLeftElement().intValue());
|
||||
assertEquals("bar", pair.getRightElement());
|
||||
assertEquals(42, pair.getLeft().intValue());
|
||||
assertEquals("bar", pair.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPairOf() throws Exception {
|
||||
MutablePair<Integer, String> pair = MutablePair.of(0, "foo");
|
||||
assertEquals(0, pair.getLeftElement().intValue());
|
||||
assertEquals("foo", pair.getRightElement());
|
||||
assertEquals(0, pair.getLeft().intValue());
|
||||
assertEquals("foo", pair.getRight());
|
||||
MutablePair<Object, String> pair2 = MutablePair.of(null, "bar");
|
||||
assertNull(pair2.getLeftElement());
|
||||
assertEquals("bar", pair2.getRightElement());
|
||||
assertNull(pair2.getLeft());
|
||||
assertEquals("bar", pair2.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue