V - is the generic type of the contained values.public class Range<V> extends Object implements Serializable, AttributeReadMinimumValue<V>, AttributeReadMaximumValue<V>
minimum and maximum. Validation is
performed at construction so a given Range should always be valid (unless
created via reflection or de-serialization). minimum and maximum value may be
null for unbounded ranges. It is still recommended to use fixed bounds such as Long.MAX_VALUE.
However, for types such as BigDecimal this is not possible.| Modifier and Type | Field and Description |
|---|---|
private V |
max |
static String |
MAX_UNBOUND
The unbound maximum.
|
private V |
min |
static String |
MIN_UNBOUND
The unbound minimum.
|
private static long |
serialVersionUID |
| Modifier | Constructor and Description |
|---|---|
protected |
Range()
The constructor for serialization.
|
|
Range(V min,
V max)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
protected Comparator<? super V> |
getComparator() |
V |
getMax()
Shorthand form for
getMaximumValue(). |
V |
getMaximumValue() |
V |
getMin()
Shorthand form for
getMinimumValue(). |
V |
getMinimumValue() |
int |
hashCode() |
boolean |
isContained(V value)
|
String |
toString() |
void |
verifyContained(V value)
This method verifies that the given
value is contained in this range . |
Range<V> |
withMax(V maximum) |
Range<V> |
withMin(V minimum) |
private static final long serialVersionUID
private V min
private V max
public static final String MIN_UNBOUND
public static final String MAX_UNBOUND
public V getMin()
getMinimumValue().null and NOT be less than max.public V getMax()
getMaximumValue().null and NOT be greater than min.public V getMinimumValue()
getMinimumValue in interface AttributeReadMinimumValue<V>getMin()public V getMaximumValue()
getMaximumValue in interface AttributeReadMaximumValue<V>getMax()public Range<V> withMin(V minimum)
minimum - the new minimum value.Range where the minimum value is set to the given min
value.public Range<V> withMax(V maximum)
maximum - the new maximum value.Range where the maximum value is set to the given max
value.protected Comparator<? super V> getComparator()
Comparator used to compare values of this
Range. The default implementation assumes that the value type implements Comparable. If you
want to use other value types you need to create a sub-class of Range and override this method.public boolean isContained(V value)
public void verifyContained(V value) throws ValueOutOfRangeException
value is contained in this range .value - is the value to check.ValueOutOfRangeException - if not contained.ValueOutOfRangeExceptionCopyright © 2001–2019 mmm-Team. All rights reserved.