public class LinearUnit extends TypedUnit<LinearUnit> implements Comparable<LinearUnit>
Modifier and Type | Class and Description |
---|---|
protected static class |
LinearUnit.Custom |
TypedUnit.UnitSelector<U extends TypedUnit<U>>
EMPTY_STRING_ARRAY
Constructor and Description |
---|
LinearUnit(LinearKindOfQuantity kindOfQuantity,
String unitId,
ScaleFactor factorToAtom,
String unitSymbol,
String unitDesc,
String... altNames) |
Modifier and Type | Method and Description |
---|---|
protected ITypedQuantity<LinearUnit> |
add(long numericalAugend,
LinearUnit addendUnit,
long numericalAddend) |
ITypedQuantity<LinearUnit> |
asWellKnownQuantity() |
int |
compareTo(LinearUnit other) |
ITypedQuantity<LinearUnit> |
customParseInteractive(String interactiveQuantity)
Parse an interactive string, like
KindOfQuantity.parseInteractive(String) , with the
addition that this unit is accepted, even if not generally by the kind of quantity. |
boolean |
equals(Object other) |
protected ITypedQuantity<LinearUnit> |
floorQuantize(double numericalValue,
ITypedQuantity<LinearUnit> quanta) |
protected ITypedQuantity<LinearUnit> |
floorQuantize(long numericalValue,
ITypedQuantity<LinearUnit> quanta) |
String[] |
getAltLocalizedNames()
Get alternate names for content assist matching.
|
String |
getAppendableSuffix(boolean useBreakingSpace)
Convenience method for (localized) formatters, to prepend a space to
IUnit.getLocalizedSymbol() , if needed. |
LinearKindOfQuantity |
getContentType()
Get the kind of quantity of this unit.
|
LinearUnit |
getDeltaUnit()
Get the unit that the difference between two quantities in this unit will have.
|
String |
getIdentifier()
Persistable identifier, not to show interactively.
|
String |
getLocalizedDescription()
In the real world, units are sometimes used ambiguously (like MB).
|
String |
getLocalizedSymbol()
Symbols for units are most often not locale dependent, but there are exceptions (like in
French).
|
protected LinearUnit |
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 Class<LinearUnit> |
getUnitClass()
|
int |
hashCode() |
protected boolean |
isCustom() |
boolean |
isLinear()
If this unit is linear.
|
protected String |
localizedFormatFor(Number numericalValue,
boolean useBreakingSpace,
boolean allowCustomUnit) |
protected String |
persistableStringFor(Number numericalValue) |
ITypedQuantity<LinearUnit> |
quantity(double numericalValue)
Create a quantity expressed in this unit and with a numerical quantity value equal to
numericalValue . |
ITypedQuantity<LinearUnit> |
quantity(long numericalValue)
Create a quantity expressed in this unit and with a numerical quantity value equal to
numericalValue . |
protected ITypedQuantity<LinearUnit> |
subtractSame(long numericalMinuend,
LinearUnit subtrahendUnit,
long numericalSubtrahend) |
String |
toString() |
ScaleFactor |
valueTransformTo(LinearUnit targetUnit)
Get a transform for transforming numerical quantity values expressed in this unit to
numerical quantity values expressed in
targetUnit . |
addPossiblyIntegral, quantity, valueTransformTo
public LinearUnit(LinearKindOfQuantity kindOfQuantity, String unitId, ScaleFactor factorToAtom, String unitSymbol, String unitDesc, String... altNames)
protected final Class<LinearUnit> getUnitClass()
TypedUnit
Class
object of the actual TypedUnit
subclass U
. This
method is intended to simplify generic code, written in TypedUnit
, to go from loosely
typed arguments into stricter parameterized arguments.getUnitClass
in class TypedUnit<LinearUnit>
public LinearKindOfQuantity getContentType()
IUnit
getContentType
in interface IUnit
getContentType
in class TypedUnit<LinearUnit>
public LinearUnit getDeltaUnit()
IUnit
getDeltaUnit
in interface IUnit
protected LinearUnit getScaledUnit(LinearUnit deltaUnit)
TypedUnit
deltaUnit
as its delta unit. Linear units
will return
deltaUnit
.getScaledUnit
in class TypedUnit<LinearUnit>
public String getAppendableSuffix(boolean useBreakingSpace)
IUnit
IUnit.getLocalizedSymbol()
, if needed.getAppendableSuffix
in interface IUnit
useBreakingSpace
- to use breaking space instead of the default, non-breaking space (only for edit)public int compareTo(LinearUnit other)
compareTo
in interface Comparable<LinearUnit>
public ITypedQuantity<LinearUnit> quantity(long numericalValue)
IUnit
numericalValue
.quantity
in interface IUnit
quantity
in class TypedUnit<LinearUnit>
public ITypedQuantity<LinearUnit> quantity(double numericalValue)
IUnit
numericalValue
.quantity
in interface IUnit
quantity
in class TypedUnit<LinearUnit>
public ScaleFactor valueTransformTo(LinearUnit targetUnit)
TypedUnit
targetUnit
. This method is typically only used
internally by the quantity implementations. Note that this method differs from
TypedUnit.valueTransformTo(IUnit)
only by stricter typing.valueTransformTo
in class TypedUnit<LinearUnit>
public boolean isLinear()
IUnit
protected ITypedQuantity<LinearUnit> add(long numericalAugend, LinearUnit addendUnit, long numericalAddend)
add
in class TypedUnit<LinearUnit>
protected ITypedQuantity<LinearUnit> subtractSame(long numericalMinuend, LinearUnit subtrahendUnit, long numericalSubtrahend)
subtractSame
in class TypedUnit<LinearUnit>
protected ITypedQuantity<LinearUnit> floorQuantize(long numericalValue, ITypedQuantity<LinearUnit> quanta)
floorQuantize
in class TypedUnit<LinearUnit>
protected ITypedQuantity<LinearUnit> floorQuantize(double numericalValue, ITypedQuantity<LinearUnit> quanta)
floorQuantize
in class TypedUnit<LinearUnit>
public String getIdentifier()
IUnit
getIdentifier
in interface IUnit
public String getLocalizedSymbol()
IUnit
While symbols normally don't contain any white space, spacing occur in circumstances like
custom units. In this case, it is important that they are non-breaking spaces
(
).
getLocalizedSymbol
in interface IUnit
public String getLocalizedDescription()
IUnit
getLocalizedDescription
in interface IUnit
public String[] getAltLocalizedNames()
IUnit
getAltLocalizedNames
in interface IUnit
null
.protected boolean isCustom()
public ITypedQuantity<LinearUnit> asWellKnownQuantity()
protected String persistableStringFor(Number numericalValue)
persistableStringFor
in class TypedUnit<LinearUnit>
protected String localizedFormatFor(Number numericalValue, boolean useBreakingSpace, boolean allowCustomUnit)
localizedFormatFor
in class TypedUnit<LinearUnit>
public ITypedQuantity<LinearUnit> customParseInteractive(String interactiveQuantity) throws QuantityConversionException
KindOfQuantity.parseInteractive(String)
, with the
addition that this unit is accepted, even if not generally by the kind of quantity. Only
guaranteed to be able to parse strings produced by
localizedFormatFor(Number, boolean, boolean)
for this unit or by
IQuantity.interactiveFormat()
for quantities of this kind of quantity, and in the
same locale. Only use this for interactive input, never for persisted strings.interactiveQuantity
- interactive string to parseQuantityConversionException
- if parsing failedCopyright © 2020. All rights reserved.