Package org.openjdk.jmc.common.unit
Class TypedUnit<U extends TypedUnit<U>>
- java.lang.Object
-
- org.openjdk.jmc.common.unit.TypedUnit<U>
-
- All Implemented Interfaces:
IUnit
- Direct Known Subclasses:
LinearUnit,TimestampUnit
public abstract class TypedUnit<U extends TypedUnit<U>> extends Object implements IUnit
Type parameterized extension ofIUnit. This construction exists to reduce clutter for casual users of IUnit, while still providing type safety for internal implementations. (Proposed "self-variance" extensions to Java, in JDK 9 or beyond, may directly support this with a single interface.)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTypedUnit.UnitSelector<U extends TypedUnit<U>>
-
Field Summary
-
Fields inherited from interface org.openjdk.jmc.common.unit.IUnit
EMPTY_STRING_ARRAY
-
-
Constructor Summary
Constructors Constructor Description TypedUnit()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ITypedQuantity<U>add(long numericalAugend, LinearUnit addendUnit, long numericalAddend)protected ITypedQuantity<U>addPossiblyIntegral(long numericalAugend, IScalarAffineTransform addendValueTransform, long numericalAddend)protected abstract ITypedQuantity<U>floorQuantize(double numericalValue, ITypedQuantity<LinearUnit> quanta)protected abstract ITypedQuantity<U>floorQuantize(long numericalValue, ITypedQuantity<LinearUnit> quanta)abstract KindOfQuantity<U>getContentType()Get the kind of quantity of this unit.protected abstract UgetScaledUnit(LinearUnit deltaUnit)Return a unit with the same origin (if absolute) as this unit, but with the givendeltaUnitas its delta unit.protected abstract Class<U>getUnitClass()protected abstract StringlocalizedFormatFor(Number numericalValue, boolean useBreakingSpace, boolean allowCustomUnit)protected abstract StringpersistableStringFor(Number numericalValue)abstract ITypedQuantity<U>quantity(double numericalValue)Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue.abstract ITypedQuantity<U>quantity(long numericalValue)Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue.ITypedQuantity<U>quantity(Number value)Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue.protected abstract ITypedQuantity<LinearUnit>subtractSame(long numericalMinuend, U subtrahendUnit, long numericalSubtrahend)IScalarAffineTransformvalueTransformTo(IUnit targetUnit)Get a transform for transforming numerical quantity values expressed in this unit to numerical quantity values expressed intargetUnit.abstract IScalarAffineTransformvalueTransformTo(U targetUnit)Get a transform for transforming numerical quantity values expressed in this unit to numerical quantity values expressed intargetUnit.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openjdk.jmc.common.unit.IUnit
getAltLocalizedNames, getAppendableSuffix, getDeltaUnit, getIdentifier, getLocalizedDescription, getLocalizedSymbol, isLinear
-
-
-
-
Method Detail
-
getScaledUnit
protected abstract U getScaledUnit(LinearUnit deltaUnit)
Return a unit with the same origin (if absolute) as this unit, but with the givendeltaUnitas its delta unit.Linear unitswill returndeltaUnit.- Throws:
IllegalArgumentException- ifdeltaUnitis of the wrong kind, although linear units are not guaranteed to verify this here
-
getContentType
public abstract KindOfQuantity<U> getContentType()
Description copied from interface:IUnitGet the kind of quantity of this unit.- Specified by:
getContentTypein interfaceIUnit
-
quantity
public ITypedQuantity<U> quantity(Number value)
Description copied from interface:IUnitCreate a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue.
-
quantity
public abstract ITypedQuantity<U> quantity(long numericalValue)
Description copied from interface:IUnitCreate a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue.
-
quantity
public abstract ITypedQuantity<U> quantity(double numericalValue)
Description copied from interface:IUnitCreate a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue.
-
valueTransformTo
public IScalarAffineTransform valueTransformTo(IUnit targetUnit)
Description copied from interface:IUnitGet a transform for transforming numerical quantity values expressed in this unit to numerical quantity values expressed intargetUnit. This method is typically only used internally by the quantity implementations.- Specified by:
valueTransformToin interfaceIUnit
-
valueTransformTo
public abstract IScalarAffineTransform valueTransformTo(U targetUnit)
Get a transform for transforming numerical quantity values expressed in this unit to numerical quantity values expressed intargetUnit. This method is typically only used internally by the quantity implementations. Note that this method differs fromvalueTransformTo(IUnit)only by stricter typing.- Throws:
IllegalArgumentException- iftargetUnitis not of the same kind of quantity
-
addPossiblyIntegral
protected final ITypedQuantity<U> addPossiblyIntegral(long numericalAugend, IScalarAffineTransform addendValueTransform, long numericalAddend)
-
add
protected abstract ITypedQuantity<U> add(long numericalAugend, LinearUnit addendUnit, long numericalAddend)
-
subtractSame
protected abstract ITypedQuantity<LinearUnit> subtractSame(long numericalMinuend, U subtrahendUnit, long numericalSubtrahend)
-
floorQuantize
protected abstract ITypedQuantity<U> floorQuantize(long numericalValue, ITypedQuantity<LinearUnit> quanta)
-
floorQuantize
protected abstract ITypedQuantity<U> floorQuantize(double numericalValue, ITypedQuantity<LinearUnit> quanta)
-
localizedFormatFor
protected abstract String localizedFormatFor(Number numericalValue, boolean useBreakingSpace, boolean allowCustomUnit)
-
-