ValueType
- The general value stored in the pair.DiscriminantType
- The discriminant comparable object used for ordering objects.public class DefaultValueDiscriminantPair<ValueType,DiscriminantType extends java.lang.Comparable<? super DiscriminantType>> extends AbstractValueDiscriminantPair<ValueType,DiscriminantType>
ValueDiscriminantPair
interface.
Stores the value and discriminant values as fields.Modifier and Type | Field and Description |
---|---|
protected DiscriminantType |
discriminant
The discriminant.
|
protected ValueType |
value
The value.
|
Constructor and Description |
---|
DefaultValueDiscriminantPair()
Creates a new
DefaultValueDiscriminantPair with null value and
discriminant. |
DefaultValueDiscriminantPair(ValueType value,
DiscriminantType discriminant)
Creates a new
DefaultValueDiscriminantPair with the given value
and discriminant. |
Modifier and Type | Method and Description |
---|---|
DefaultValueDiscriminantPair<ValueType,DiscriminantType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
static <ValueType,DiscriminantType extends java.lang.Comparable<? super DiscriminantType>> |
create(ValueType value,
DiscriminantType discriminant)
Convenience method for creating a new
DefaultValueDiscriminantPair with the given value and
discriminant. |
DiscriminantType |
getDiscriminant()
Gets the discriminant for ordering instances of the same value.
|
ValueType |
getValue()
Gets the value in the pair.
|
void |
setDiscriminant(DiscriminantType discriminant)
Sets the discriminant.
|
void |
setValue(ValueType value)
Sets the value.
|
getFirst, getSecond
protected ValueType value
protected DiscriminantType extends java.lang.Comparable<? super DiscriminantType> discriminant
public DefaultValueDiscriminantPair()
DefaultValueDiscriminantPair
with null value and
discriminant.public DefaultValueDiscriminantPair(ValueType value, DiscriminantType discriminant)
DefaultValueDiscriminantPair
with the given value
and discriminant.value
- The value.discriminant
- The discriminant.public DefaultValueDiscriminantPair<ValueType,DiscriminantType> clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public ValueType getValue()
ValueDiscriminantPair
public void setValue(ValueType value)
value
- The value.public DiscriminantType getDiscriminant()
ValueDiscriminantPair
public void setDiscriminant(DiscriminantType discriminant)
discriminant
- The discriminant.public static <ValueType,DiscriminantType extends java.lang.Comparable<? super DiscriminantType>> DefaultValueDiscriminantPair<ValueType,DiscriminantType> create(ValueType value, DiscriminantType discriminant)
DefaultValueDiscriminantPair
with the given value and
discriminant.ValueType
- The general value stored in the pair.DiscriminantType
- The discriminant comparable object used for ordering objects.value
- The value.discriminant
- The discriminant.DefaultValueDiscriminantPair
.