ValueType
- Type of the value contained in the class@CodeReview(reviewer="Kevin R. Dixon", date="2007-11-25", changesNeeded=false, comments="Looks fine.") public class DefaultWeightedValue<ValueType> extends AbstractWeighted implements WeightedValue<ValueType>
WeightedValue
class implements a simple generic container
that holds a value and a weight assigned to the value.Modifier and Type | Class and Description |
---|---|
static class |
DefaultWeightedValue.WeightComparator
A comparator for weighted values based on the weight.
|
Modifier and Type | Field and Description |
---|---|
protected ValueType |
value
The value.
|
DEFAULT_WEIGHT, weight
Constructor and Description |
---|
DefaultWeightedValue()
Creates a new instance of
WeightedValue . |
DefaultWeightedValue(ValueType value)
Creates a new instance of
WeightedValue with the given value
and a default weight of
1.0. |
DefaultWeightedValue(ValueType value,
double weight)
Creates a new instance of
WeightedValue . |
DefaultWeightedValue(WeightedValue<? extends ValueType> other)
Creates a new shallow copy of a
WeightedValue . |
Modifier and Type | Method and Description |
---|---|
DefaultWeightedValue<ValueType> |
clone()
Creates a shallow copy of the WeightedValue.
|
static <ValueType> |
create(ValueType value,
double weight)
Convenience method to create a new
WeightedValue . |
ValueType |
getValue()
Gets the value.
|
void |
setValue(ValueType value)
Sets the value.
|
getWeight, setWeight
protected ValueType value
public DefaultWeightedValue()
WeightedValue
. The weight defaults to
1.0 and
the value defaults to null.public DefaultWeightedValue(ValueType value)
WeightedValue
with the given value
and a default weight of
1.0.value
- The value.public DefaultWeightedValue(ValueType value, double weight)
WeightedValue
.weight
- The weight.value
- The value.public DefaultWeightedValue(WeightedValue<? extends ValueType> other)
WeightedValue
.other
- The WeightedValue
to shallow copy.public DefaultWeightedValue<ValueType> clone()
clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
WeightedValue
.public ValueType getValue()
getValue
in interface WeightedValue<ValueType>
public void setValue(ValueType value)
value
- The value.public static <ValueType> DefaultWeightedValue<ValueType> create(ValueType value, double weight)
WeightedValue
.ValueType
- The type of the value.value
- The value.weight
- The weight.