Package org.openjdk.jmc.common.unit
Class QuantityRange<U extends TypedUnit<U>>
- java.lang.Object
-
- org.openjdk.jmc.common.unit.QuantityRange<U>
-
- All Implemented Interfaces:
IDisplayable
,IRange<IQuantity>
- Direct Known Subclasses:
QuantityRange.Point
,QuantityRange.WithEnd
,QuantityRange.WithExtent
public abstract class QuantityRange<U extends TypedUnit<U>> extends java.lang.Object implements IRange<IQuantity>
A finite range of quantities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
QuantityRange.Point<U extends TypedUnit<U>>
private static class
QuantityRange.WithEnd<U extends TypedUnit<U>>
private static class
QuantityRange.WithExtent<U extends TypedUnit<U>>
-
Field Summary
Fields Modifier and Type Field Description protected ITypedQuantity<U>
start
-
Fields inherited from interface org.openjdk.jmc.common.IDisplayable
AUTO, EXACT, VERBOSE
-
-
Constructor Summary
Constructors Modifier Constructor Description private
QuantityRange(ITypedQuantity<U> start)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static IDisplayable
createInfinite(IQuantity start, IQuantity end)
static <U extends TypedUnit<U>>
IRange<IQuantity>createPoint(IQuantity start)
static <U extends TypedUnit<U>>
IRange<IQuantity>createWithEnd(IQuantity start, IQuantity end)
static <U extends TypedUnit<U>>
IRange<IQuantity>createWithExtent(IQuantity start, ITypedQuantity<LinearUnit> extent)
java.lang.String
displayUsing(java.lang.String formatHint)
Format this object for display purposes, preferably using the formatter hinted byformatHint
.abstract ITypedQuantity<U>
getEnd()
ITypedQuantity<U>
getStart()
static IRange<IQuantity>
intersection(IRange<IQuantity> a, IRange<IQuantity> b)
-
-
-
Field Detail
-
start
protected final ITypedQuantity<U extends TypedUnit<U>> start
-
-
Constructor Detail
-
QuantityRange
private QuantityRange(ITypedQuantity<U> start)
-
-
Method Detail
-
createWithEnd
public static <U extends TypedUnit<U>> IRange<IQuantity> createWithEnd(IQuantity start, IQuantity end)
-
createWithExtent
public static <U extends TypedUnit<U>> IRange<IQuantity> createWithExtent(IQuantity start, ITypedQuantity<LinearUnit> extent)
-
createInfinite
public static IDisplayable createInfinite(IQuantity start, IQuantity end)
Create anIRange<IQuantity>
ifstart
andend
both are non-null. Otherwise, create anIDisplayable
that looks like an infinite range, by treating null values as minus or plus infinity, respectively. This behavior is a consequence of the current state whereIQuantity
and thuslyIRange<IQuantity>
both need to be finite. (A possible change to this state, when all kinds of quantities support being stored as doubles, is to allowDouble.NEGATIVE_INFINITY
andDouble.POSITIVE_INFINITY
as numerical quantities. In that case, this method can be replaced withcreateWithEnd(IQuantity, IQuantity)
).
-
intersection
public static IRange<IQuantity> intersection(IRange<IQuantity> a, IRange<IQuantity> b)
-
getStart
public ITypedQuantity<U> getStart()
-
getEnd
public abstract ITypedQuantity<U> getEnd()
-
displayUsing
public java.lang.String displayUsing(java.lang.String formatHint)
Description copied from interface:IDisplayable
Format this object for display purposes, preferably using the formatter hinted byformatHint
. If no such formatter is defined for this type, the default formatter will be used.- Specified by:
displayUsing
in interfaceIDisplayable
- Parameters:
formatHint
- the format hint- Returns:
- a formatted string according to the hinted (or default) formatter
-
-