Package com.globalmentor.model
Class NameValuePair<N,V>
- java.lang.Object
-
- com.globalmentor.model.DefaultNamed<N>
-
- com.globalmentor.model.NameValuePair<N,V>
-
- Direct Known Subclasses:
ContentType.Parameter
,NameValuePairMapEntry
,URIQueryParameter
public class NameValuePair<N,V> extends DefaultNamed<N> implements IDed<N>, Valued<V>
A convenience tuple for a name and a value. The class allows identification (though not necessarily unique) through its name object.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description NameValuePair(N newName, V newValue)
Constructor specifying the name and value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object object)
Determines if the given object is another name value pair with the same name and value.static <MEK,MEV>
NameValuePair<MEK,MEV>fromMapEntry(java.util.Map.Entry<MEK,MEV> mapEntry)
Static factory method to create a name-value pair from a map entry copy.N
getID()
V
getValue()
int
hashCode()
java.lang.String
toString()
-
Methods inherited from class com.globalmentor.model.DefaultNamed
getName
-
-
-
-
Method Detail
-
getValue
public V getValue()
-
getID
public N getID()
-
fromMapEntry
public static <MEK,MEV> NameValuePair<MEK,MEV> fromMapEntry(@Nonnull java.util.Map.Entry<MEK,MEV> mapEntry)
Static factory method to create a name-value pair from a map entry copy.- Type Parameters:
MEK
- The type of map entry key.MEV
- The type of map entry value.- Parameters:
mapEntry
- The map entry the values of which to use in creating this name/value pair.- Returns:
- A name-value pair from the map entry.
- Throws:
java.lang.NullPointerException
- if the given map entry isnull
.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classDefaultNamed<N>
- Returns:
- A hashcode value composed from the name.
-
equals
public boolean equals(java.lang.Object object)
Determines if the given object is another name value pair with the same name and value.- Overrides:
equals
in classDefaultNamed<N>
- Parameters:
object
- The object with which to compare this name/value pair.- Returns:
true
if this name/value pair equals that specified inobject
.- See Also:
DefaultNamed.getName()
,getValue()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classDefaultNamed<N>
- Returns:
- A string representation of this object in the format "name=\"value\"".
-
-