From aaa866d0d6b1f41e955ba6334386846029788afe Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Sat, 27 Sep 2003 10:33:34 +0000 Subject: [PATCH] Rename Pair to KeyValue git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131195 13f79535-47bb-0310-9956-ffa450edef68 --- ...bstractPair.java => AbstractKeyValue.java} | 10 ++--- .../collections/pairs/AbstractMapEntry.java | 6 +-- ...KeyValuePair.java => DefaultKeyValue.java} | 38 ++++++++++--------- .../collections/pairs/DefaultMapEntry.java | 12 +++--- .../pairs/{Pair.java => KeyValue.java} | 8 ++-- 5 files changed, 38 insertions(+), 36 deletions(-) rename src/java/org/apache/commons/collections/pairs/{AbstractPair.java => AbstractKeyValue.java} (91%) rename src/java/org/apache/commons/collections/pairs/{KeyValuePair.java => DefaultKeyValue.java} (83%) rename src/java/org/apache/commons/collections/pairs/{Pair.java => KeyValue.java} (93%) diff --git a/src/java/org/apache/commons/collections/pairs/AbstractPair.java b/src/java/org/apache/commons/collections/pairs/AbstractKeyValue.java similarity index 91% rename from src/java/org/apache/commons/collections/pairs/AbstractPair.java rename to src/java/org/apache/commons/collections/pairs/AbstractKeyValue.java index 638bf2ea4..8eb46be00 100644 --- a/src/java/org/apache/commons/collections/pairs/AbstractPair.java +++ b/src/java/org/apache/commons/collections/pairs/AbstractKeyValue.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/AbstractPair.java,v 1.1 2003/09/25 22:47:49 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/AbstractKeyValue.java,v 1.1 2003/09/27 10:33:34 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -58,17 +58,17 @@ package org.apache.commons.collections.pairs; /** - * Abstract Pair class to assist with creating Pair and Map Entry implementations. + * Abstract pair class to assist with creating KeyValue and MapEntry implementations. * * @since Commons Collections 3.0 - * @version $Revision: 1.1 $ $Date: 2003/09/25 22:47:49 $ + * @version $Revision: 1.1 $ $Date: 2003/09/27 10:33:34 $ * * @author James Strachan * @author Michael A. Smith * @author Neil O'Toole * @author Stephen Colebourne */ -public abstract class AbstractPair { +public abstract class AbstractKeyValue implements KeyValue { /** The key */ protected Object key; @@ -81,7 +81,7 @@ public abstract class AbstractPair { * @param key the key for the entry, may be null * @param value the value for the entry, may be null */ - protected AbstractPair(Object key, Object value) { + protected AbstractKeyValue(Object key, Object value) { super(); this.key = key; this.value = value; diff --git a/src/java/org/apache/commons/collections/pairs/AbstractMapEntry.java b/src/java/org/apache/commons/collections/pairs/AbstractMapEntry.java index e73c3639e..44b7152ca 100644 --- a/src/java/org/apache/commons/collections/pairs/AbstractMapEntry.java +++ b/src/java/org/apache/commons/collections/pairs/AbstractMapEntry.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/AbstractMapEntry.java,v 1.1 2003/09/25 22:47:49 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/AbstractMapEntry.java,v 1.2 2003/09/27 10:33:34 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -63,14 +63,14 @@ import java.util.Map; * Abstract Pair class to assist with creating correct Map Entry implementations. * * @since Commons Collections 3.0 - * @version $Revision: 1.1 $ $Date: 2003/09/25 22:47:49 $ + * @version $Revision: 1.2 $ $Date: 2003/09/27 10:33:34 $ * * @author James Strachan * @author Michael A. Smith * @author Neil O'Toole * @author Stephen Colebourne */ -public class AbstractMapEntry extends AbstractPair implements Map.Entry { +public class AbstractMapEntry extends AbstractKeyValue implements Map.Entry { /** * Constructs a new entry with the given key and given value. diff --git a/src/java/org/apache/commons/collections/pairs/KeyValuePair.java b/src/java/org/apache/commons/collections/pairs/DefaultKeyValue.java similarity index 83% rename from src/java/org/apache/commons/collections/pairs/KeyValuePair.java rename to src/java/org/apache/commons/collections/pairs/DefaultKeyValue.java index 5208dd982..244b53fa1 100644 --- a/src/java/org/apache/commons/collections/pairs/KeyValuePair.java +++ b/src/java/org/apache/commons/collections/pairs/DefaultKeyValue.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/KeyValuePair.java,v 1.1 2003/09/25 22:47:49 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/DefaultKeyValue.java,v 1.1 2003/09/27 10:33:34 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -60,25 +60,25 @@ package org.apache.commons.collections.pairs; import java.util.Map; /** - * A mutable key-value pair that does not implement Map Entry. + * A mutable KeyValue pair that does not implement MapEntry. *

- * Note that a KeyValuePair instance may not contain + * Note that a DefaultKeyValue instance may not contain * itself as a key or value. * * @since Commons Collections 3.0 - * @version $Revision: 1.1 $ $Date: 2003/09/25 22:47:49 $ + * @version $Revision: 1.1 $ $Date: 2003/09/27 10:33:34 $ * * @author James Strachan * @author Michael A. Smith * @author Neil O'Toole * @author Stephen Colebourne */ -public class KeyValuePair extends AbstractPair { +public class DefaultKeyValue extends AbstractKeyValue { /** * Constructs a new pair with a null key and null value. */ - public KeyValuePair() { + public DefaultKeyValue() { super(null, null); } @@ -88,27 +88,27 @@ public class KeyValuePair extends AbstractPair { * @param key the key for the entry, may be null * @param value the value for the entry, may be null */ - public KeyValuePair(final Object key, final Object value) { + public DefaultKeyValue(final Object key, final Object value) { super(key, value); } /** - * Constructs a new pair from the specified Pair. + * Constructs a new pair from the specified KeyValue. * * @param pair the pair to copy, must not be null * @throws NullPointerException if the entry is null */ - public KeyValuePair(final Pair pair) { + public DefaultKeyValue(final KeyValue pair) { super(pair.getKey(), pair.getValue()); } /** - * Constructs a new pair from the specified Map Entry. + * Constructs a new pair from the specified MapEntry. * * @param entry the entry to copy, must not be null * @throws NullPointerException if the entry is null */ - public KeyValuePair(final Map.Entry entry) { + public DefaultKeyValue(final Map.Entry entry) { super(entry.getKey(), entry.getValue()); } @@ -122,7 +122,7 @@ public class KeyValuePair extends AbstractPair { */ public Object setKey(final Object key) { if (key == this) { - throw new IllegalArgumentException("A KeyValuePair may not contain itself as a key."); + throw new IllegalArgumentException("DefaultKeyValue may not contain itself as a key."); } final Object old = this.key; @@ -139,7 +139,7 @@ public class KeyValuePair extends AbstractPair { */ public Object setValue(final Object value) { if (value == this) { - throw new IllegalArgumentException("A KeyValuePair may not contain itself as a value."); + throw new IllegalArgumentException("DefaultKeyValue may not contain itself as a value."); } final Object old = this.value; @@ -149,17 +149,19 @@ public class KeyValuePair extends AbstractPair { //----------------------------------------------------------------------- /** - * Returns a new Map.Entry object with key and value from this KeyValuePair. + * Returns a new Map.Entry object with key and value from this pair. + * + * @return a MapEntry instance */ public Map.Entry toMapEntry() { - return new DefaultMapEntry(this.getKey(), this.getValue()); + return new DefaultMapEntry(this); } //----------------------------------------------------------------------- /** * Compares this Map Entry with another Map Entry. *

- * Returns true if the compared object is also a KeyValuePair, + * Returns true if the compared object is also a DefaultKeyValue, * and its key and value are equal to this object's key and value. * * @param obj the object to compare to @@ -169,11 +171,11 @@ public class KeyValuePair extends AbstractPair { if (obj == this) { return true; } - if (obj instanceof KeyValuePair == false) { + if (obj instanceof DefaultKeyValue == false) { return false; } - KeyValuePair other = (KeyValuePair) obj; + DefaultKeyValue other = (DefaultKeyValue) obj; return (getKey() == null ? other.getKey() == null : getKey().equals(other.getKey())) && (getValue() == null ? other.getValue() == null : getValue().equals(other.getValue())); diff --git a/src/java/org/apache/commons/collections/pairs/DefaultMapEntry.java b/src/java/org/apache/commons/collections/pairs/DefaultMapEntry.java index 5e90e4baf..be752b5b4 100644 --- a/src/java/org/apache/commons/collections/pairs/DefaultMapEntry.java +++ b/src/java/org/apache/commons/collections/pairs/DefaultMapEntry.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/DefaultMapEntry.java,v 1.1 2003/09/25 22:47:49 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/DefaultMapEntry.java,v 1.2 2003/09/27 10:33:34 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -61,10 +61,10 @@ import java.util.Map; /** * A restricted implementation of {@link java.util.Map.Entry} that prevents - * the Map Entry contract from being broken. + * the MapEntry contract from being broken. * * @since Commons Collections 3.0 - * @version $Revision: 1.1 $ $Date: 2003/09/25 22:47:49 $ + * @version $Revision: 1.2 $ $Date: 2003/09/27 10:33:34 $ * * @author James Strachan * @author Michael A. Smith @@ -84,17 +84,17 @@ public final class DefaultMapEntry extends AbstractMapEntry { } /** - * Constructs a new entry from the specified Pair. + * Constructs a new entry from the specified KeyValue. * * @param pair the pair to copy, must not be null * @throws NullPointerException if the entry is null */ - public DefaultMapEntry(final Pair pair) { + public DefaultMapEntry(final KeyValue pair) { super(pair.getKey(), pair.getValue()); } /** - * Constructs a new entry from the specified Map Entry. + * Constructs a new entry from the specified MapEntry. * * @param entry the entry to copy, must not be null * @throws NullPointerException if the entry is null diff --git a/src/java/org/apache/commons/collections/pairs/Pair.java b/src/java/org/apache/commons/collections/pairs/KeyValue.java similarity index 93% rename from src/java/org/apache/commons/collections/pairs/Pair.java rename to src/java/org/apache/commons/collections/pairs/KeyValue.java index ad434137d..cdcce111d 100644 --- a/src/java/org/apache/commons/collections/pairs/Pair.java +++ b/src/java/org/apache/commons/collections/pairs/KeyValue.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/Pair.java,v 1.1 2003/09/25 22:47:49 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/pairs/Attic/KeyValue.java,v 1.1 2003/09/27 10:33:34 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -58,14 +58,14 @@ package org.apache.commons.collections.pairs; /** - * Defines a simple key value Pair. + * Defines a simple key value pair. * * @since Commons Collections 3.0 - * @version $Revision: 1.1 $ $Date: 2003/09/25 22:47:49 $ + * @version $Revision: 1.1 $ $Date: 2003/09/27 10:33:34 $ * * @author Stephen Colebourne */ -public interface Pair { +public interface KeyValue { /** * Gets the key from the pair.