gov.sandia.cognition.util
Class DefaultIdentifiedValue<IdentifierType,ValueType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.util.DefaultIdentifiedValue<IdentifierType,ValueType>
Type Parameters:
IdentifierType - The type of identifier for the value. Must implement valid equals and hashCode methods.
ValueType - The type of value stored with the identifier.
All Implemented Interfaces:
CloneableSerializable, Identified<IdentifierType>, IdentifiedValue<IdentifierType,ValueType>, Serializable, Cloneable

public class DefaultIdentifiedValue<IdentifierType,ValueType>
extends AbstractCloneableSerializable
implements IdentifiedValue<IdentifierType,ValueType>

A default implementation of the IdentifiedValue interface that stores a value along with its identifier.

Since:
3.3.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
protected  IdentifierType identifier
          The identifier for the value.
protected  ValueType value
          The value.
 
Constructor Summary
DefaultIdentifiedValue()
          Creates a new DefaultIdentifiedValue with null identifier and value.
DefaultIdentifiedValue(IdentifierType identifier, ValueType value)
          Creates a new DefaultIdentifiedValue with the given identifier and value.
 
Method Summary
static
<IdentifierType,ValueType>
DefaultIdentifiedValue<IdentifierType,ValueType>
create()
          Convenience method to create a new, empty DefaultIdentifiedValue.
static
<IdentifierType,ValueType>
DefaultIdentifiedValue<IdentifierType,ValueType>
create(IdentifierType identifier, ValueType value)
          Creates a new DefaultIdentifiedValue with the given identifier and value.
 IdentifierType getIdentifier()
          Gets the identifier for this object.
 ValueType getValue()
          Gets the value associated with the identifier.
 void setIdentifier(IdentifierType identifier)
          Sets the identifier.
 void setValue(ValueType value)
          Sets the value.
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

identifier

protected IdentifierType identifier
The identifier for the value.


value

protected ValueType value
The value.

Constructor Detail

DefaultIdentifiedValue

public DefaultIdentifiedValue()
Creates a new DefaultIdentifiedValue with null identifier and value.


DefaultIdentifiedValue

public DefaultIdentifiedValue(IdentifierType identifier,
                              ValueType value)
Creates a new DefaultIdentifiedValue with the given identifier and value.

Parameters:
identifier - The identifier for the value.
value - The value.
Method Detail

getIdentifier

public IdentifierType getIdentifier()
Description copied from interface: Identified
Gets the identifier for this object.

Specified by:
getIdentifier in interface Identified<IdentifierType>
Returns:
The identifier for this object.

setIdentifier

public void setIdentifier(IdentifierType identifier)
Sets the identifier.

Parameters:
identifier - The identifier for the value.

getValue

public ValueType getValue()
Description copied from interface: IdentifiedValue
Gets the value associated with the identifier.

Specified by:
getValue in interface IdentifiedValue<IdentifierType,ValueType>
Returns:
The value associated with the identifier.

setValue

public void setValue(ValueType value)
Sets the value.

Parameters:
value - The value associated with the identifier.

create

public static <IdentifierType,ValueType> DefaultIdentifiedValue<IdentifierType,ValueType> create()
Convenience method to create a new, empty DefaultIdentifiedValue.

Type Parameters:
IdentifierType - The type of identifier for the value. Must implement valid equals and hashCode methods.
ValueType - The type of value stored.
Returns:
A new, empty DefaultIdentifiedValue.

create

public static <IdentifierType,ValueType> DefaultIdentifiedValue<IdentifierType,ValueType> create(IdentifierType identifier,
                                                                                                 ValueType value)
Creates a new DefaultIdentifiedValue with the given identifier and value.

Type Parameters:
IdentifierType - The type of identifier for the value. Must implement valid equals and hashCode methods.
ValueType - The type of value stored.
Parameters:
identifier - The identifier for the value.
value - The value.
Returns:
A new DefaultIdentifiedValue with the given identifier and value.