- Type Parameters:
V- type of the contained values.
- All Known Subinterfaces:
WritableRange<V>
- All Known Implementing Classes:
AbstractRange,NumberRangeType,RangeType
public interface Range<V extends Comparable<?>>
This class represents a range from
ATTENTION:
The
minimum to maximum. Implementations shall
validate at construction so a given Range should always be valid. ATTENTION:
The
minimum and maximum 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.- Since:
- 1.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charChar indicating end with exclusive maximum.static final charChar indicating end with inclusive maximum.static final charChar to separate minimum and maximum.static final charChar indicating start with exclusive minimum.static final charChar indicating start with inclusive minimum.static final StringThe unbound maximum.static final StringThe unbound minimum.static final StringProperty name ofgetMax().static final StringProperty name ofgetMin(). -
Method Summary
Modifier and TypeMethodDescriptiondefault Vdefault booleandefault Comparator<? super V> getMax()getMin()intersection(Range<V> range) static <T extends Comparable<?>>
Range<T> invalid()default booleanstatic <T extends Comparable<?>>
Range<T> of(T min, T max) static <T extends Comparable<?>>
Range<T>
-
Field Details
-
BOUND_START_INCLUSIVE
static final char BOUND_START_INCLUSIVEChar indicating start with inclusive minimum.- See Also:
-
BOUND_START_EXCLUSIVE
static final char BOUND_START_EXCLUSIVEChar indicating start with exclusive minimum.- See Also:
-
BOUND_END_INCLUSIVE
static final char BOUND_END_INCLUSIVEChar indicating end with inclusive maximum.- See Also:
-
BOUND_END_EXCLUSIVE
static final char BOUND_END_EXCLUSIVEChar indicating end with exclusive maximum.- See Also:
-
BOUND_SEPARATOR
static final char BOUND_SEPARATORChar to separate minimum and maximum. Mathematical convention would be to use a comma (','), but this causes problems when parsingstring representationsas a comma may also occur in the minimum or maximum value.- See Also:
-
MIN_UNBOUND
The unbound minimum.- See Also:
-
MAX_UNBOUND
The unbound maximum.- See Also:
-
PROPERTY_MIN
Property name ofgetMin().- See Also:
-
PROPERTY_MAX
Property name ofgetMax().- See Also:
-
-
Method Details
-
getMin
V getMin()- Returns:
- the lower bound of this range or
nullif no lower bound is defined. Has to be less thanmaxif both boundaries are notnull.
-
getMax
V getMax()- Returns:
- the upper bound of this range or
nullif no upper bound is defined. Has to be greater thanminif both boundaries are notnull.
-
getComparator
- Returns:
- the
Comparatorused tocomparevalues of thisRange. The default implementation assumes that the value type implementsComparable. If you want to use other value types you need to override this method.
-
contains
-
clip
-
withMin
-
withMax
-
intersection
-
isUnbounded
default boolean isUnbounded() -
of
- Type Parameters:
T- type of thecontained value.- Parameters:
min- theminimum.max- themaximum.- Returns:
- the specified
Range.
-
unbounded
- Type Parameters:
T- type of thecontained value.- Returns:
- the unbounded
Rangeinstancecontainingall values (withgetMin()andgetMax()beingnull).
-
invalid
- Type Parameters:
T- type of thecontained value.- Returns:
- the invalid
Rangeinstancecontainingno values at all (withgetMin()andgetMax()beingnull).
-