HiRISE

HiRISE.HiPlan.Utilities
Class KeyValuePair

java.lang.Object
  extended by HiRISE.HiPlan.Utilities.KeyValuePair
All Implemented Interfaces:
Comparable<KeyValuePair>

public class KeyValuePair
extends Object
implements Comparable<KeyValuePair>

A simple key-value pair association. The class is immutable.

There is nothing inherently key-like or value-like about the two elements, so this class could be used for any pair of strings.

(Lifted from PlanC.)

Version:
1.0
Author:
Christian Schaller - UA/LPL/PIRL

Field Summary
static String ID
          Class identification name with source code version and date.
 
Constructor Summary
KeyValuePair(String key, String value)
          Creates a new key-value pair with the indicated key and value.
 
Method Summary
 int compareTo(KeyValuePair p)
          Compares this key-value pair to another according to the natural sort order of their components.
 boolean equals(Object o)
          Indicates whether some other object is "equal to" this one.
 String getKey()
          Gets the pair's key.
 String getValue()
          Gets the pair's value.
 int hashCode()
          Returns a hash code value for this key-value pair.
 String toString()
          Gets a string representation of this key-value pair.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values
Constructor Detail

KeyValuePair

public KeyValuePair(String key,
                    String value)
Creates a new key-value pair with the indicated key and value. Neither the key nor the value may be null, or a NullPointerException will be thrown.

Parameters:
key - the pair's key; may not be null.
value - the pair's value; may not be null.
Throws:
NullPointerException - if either the key or the value is null.
Method Detail

getKey

public String getKey()
Gets the pair's key.

Returns:
the pair's key; is not null.

getValue

public String getValue()
Gets the pair's value.

Returns:
the pair's value; is not null.

equals

public boolean equals(Object o)
Indicates whether some other object is "equal to" this one. A key-value pair is equal to another if and only if the two keys are equal and the two values are equal.

Overrides:
equals in class Object
Parameters:
o - the object to which this object is compared.
Returns:
true if the objects are equal; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for this key-value pair.

Overrides:
hashCode in class Object
Returns:
a hash code value for this key-value pair.

toString

public String toString()
Gets a string representation of this key-value pair. The string is of the following form:
        org.uahirise.cassis.plan.util.KeyValuePair[key=KEY,value=VALUE]

Overrides:
toString in class Object
Returns:
a string representation of this key-value pair.

compareTo

public int compareTo(KeyValuePair p)
Compares this key-value pair to another according to the natural sort order of their components. The keys are compared first, followed by their values if the keys are equal.

Specified by:
compareTo in interface Comparable<KeyValuePair>
Parameters:
p - another key-value pair to compare to this one.
Returns:
a negative integer, zero, or a positive integer as this pair is less than, equal to, or greater than the specified pair.
See Also:
String.compareTo(String)

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona