public abstract class TypedUnit<U extends TypedUnit<U>> extends Object implements IUnit
IUnit
. 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.)Modifier and Type | Class and Description |
---|---|
static interface |
TypedUnit.UnitSelector<U extends TypedUnit<U>> |
EMPTY_STRING_ARRAY
Constructor and Description |
---|
TypedUnit() |
Modifier and Type | Method and 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 U |
getScaledUnit(LinearUnit deltaUnit)
Return a unit with the same origin (if absolute) as this unit, but with the given
deltaUnit as its delta unit. |
protected abstract Class<U> |
getUnitClass()
|
protected abstract String |
localizedFormatFor(Number numericalValue,
boolean useBreakingSpace,
boolean allowCustomUnit) |
protected abstract String |
persistableStringFor(Number numericalValue) |
abstract ITypedQuantity<U> |
quantity(double numericalValue)
Create a quantity expressed in this unit and with a numerical quantity value equal to
numericalValue . |
abstract ITypedQuantity<U> |
quantity(long numericalValue)
Create a quantity expressed in this unit and with a numerical quantity value equal to
numericalValue . |
ITypedQuantity<U> |
quantity(Number value)
Create a quantity expressed in this unit and with a numerical quantity value equal to
numericalValue . |
protected abstract ITypedQuantity<LinearUnit> |
subtractSame(long numericalMinuend,
U subtrahendUnit,
long numericalSubtrahend) |
IScalarAffineTransform |
valueTransformTo(IUnit targetUnit)
Get a transform for transforming numerical quantity values expressed in this unit to
numerical quantity values expressed in
targetUnit . |
abstract IScalarAffineTransform |
valueTransformTo(U targetUnit)
Get a transform for transforming numerical quantity values expressed in this unit to
numerical quantity values expressed in
targetUnit . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAltLocalizedNames, getAppendableSuffix, getDeltaUnit, getIdentifier, getLocalizedDescription, getLocalizedSymbol, isLinear
protected abstract U getScaledUnit(LinearUnit deltaUnit)
deltaUnit
as its delta unit. Linear units
will return
deltaUnit
.IllegalArgumentException
- if deltaUnit
is of the wrong kind, although linear units are not
guaranteed to verify this herepublic abstract KindOfQuantity<U> getContentType()
IUnit
getContentType
in interface IUnit
public ITypedQuantity<U> quantity(Number value)
IUnit
numericalValue
.public abstract ITypedQuantity<U> quantity(long numericalValue)
IUnit
numericalValue
.public abstract ITypedQuantity<U> quantity(double numericalValue)
IUnit
numericalValue
.public IScalarAffineTransform valueTransformTo(IUnit targetUnit)
IUnit
targetUnit
. This method is typically only used
internally by the quantity implementations.valueTransformTo
in interface IUnit
public abstract IScalarAffineTransform valueTransformTo(U targetUnit)
targetUnit
. This method is typically only used
internally by the quantity implementations. Note that this method differs from
valueTransformTo(IUnit)
only by stricter typing.IllegalArgumentException
- if targetUnit
is not of the same kind of quantityprotected final ITypedQuantity<U> addPossiblyIntegral(long numericalAugend, IScalarAffineTransform addendValueTransform, long numericalAddend)
protected abstract ITypedQuantity<U> add(long numericalAugend, LinearUnit addendUnit, long numericalAddend)
protected abstract ITypedQuantity<LinearUnit> subtractSame(long numericalMinuend, U subtrahendUnit, long numericalSubtrahend)
protected abstract ITypedQuantity<U> floorQuantize(long numericalValue, ITypedQuantity<LinearUnit> quanta)
protected abstract ITypedQuantity<U> floorQuantize(double numericalValue, ITypedQuantity<LinearUnit> quanta)
protected abstract String localizedFormatFor(Number numericalValue, boolean useBreakingSpace, boolean allowCustomUnit)
Copyright © 2020. All rights reserved.