Package org.openwms.core.units.api
Class MetricDimension
java.lang.Object
org.openwms.core.units.api.MetricDimension
- All Implemented Interfaces:
Serializable,Comparable<MetricDimension>,Measurable<BigDecimal,MetricDimension, MetricDimensionUnit>
public class MetricDimension
extends Object
implements Measurable<BigDecimal,MetricDimension,MetricDimensionUnit>, Serializable
A MetricDimension represents metric dimensional units, like meters.
- Author:
- Heiko Scherrer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BigDecimalThe magnitude of the MetricDimensionUnit.private MetricDimensionUnitThe unit of the MetricDimension.static final MetricDimensionConstant for a zero value.Fields inherited from interface org.openwms.core.units.api.Measurable
SEPARATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAccessed by persistence provider.privateMetricDimension(BigDecimal magnitude, MetricDimensionUnit unitType) Create a new MetricDimension. -
Method Summary
Modifier and TypeMethodDescriptionAdd anotherMeasurable to this one.intConvert thisMeasurableinto anotherMeasurable.booleanUses magnitude and unitType for comparison.Get the magnitude of thisMeasurable.Returns the type ofMeasurable.inthashCode()Uses magnitude and unitType for calculation.booleanCheck whether the magnitude is of negative value.booleanisZero()Check whether the magnitude is 0.static MetricDimensionof(int magnitude) Create a new MetricDimension.static MetricDimensionof(int magnitude, MetricDimensionUnit unitType) Create a new MetricDimension.static MetricDimensionof(BigDecimal magnitude) Create a new MetricDimension.static MetricDimensionof(BigDecimal magnitude, MetricDimensionUnit unitType) Create a new MetricDimension.subtract(Measurable<BigDecimal, MetricDimension, MetricDimensionUnit> subtrahent) Subtract anotherMeasurable instance from this one.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openwms.core.units.api.Measurable
asString
-
Field Details
-
unitType
The unit of the MetricDimension. -
magnitude
The magnitude of the MetricDimensionUnit. -
ZERO
Constant for a zero value.
-
-
Constructor Details
-
MetricDimension
protected MetricDimension()Accessed by persistence provider. -
MetricDimension
Create a new MetricDimension.- Parameters:
magnitude- The magnitudeunitType- The unit of measure
-
-
Method Details
-
of
Create a new MetricDimension.- Parameters:
magnitude- The magnitudeunitType- The unit of measure- Returns:
- The new instance
-
of
Create a new MetricDimension.- Parameters:
magnitude- The magnitude- Returns:
- The new instance
-
of
Create a new MetricDimension.- Parameters:
magnitude- The magnitudeunitType- The unit of measure- Returns:
- The new instance
-
of
Create a new MetricDimension.- Parameters:
magnitude- The magnitude- Returns:
- The new instance
-
getMagnitude
Get the magnitude of thisMeasurable.- Specified by:
getMagnitudein interfaceMeasurable<BigDecimal,MetricDimension, MetricDimensionUnit> - Returns:
- the magnitude
-
getUnitType
Returns the type ofMeasurable.- Specified by:
getUnitTypein interfaceMeasurable<BigDecimal,MetricDimension, MetricDimensionUnit> - Returns:
- The
Measurable's type
-
isZero
public boolean isZero()Check whether the magnitude is 0.- Specified by:
isZeroin interfaceMeasurable<BigDecimal,MetricDimension, MetricDimensionUnit> - Returns:
- true is magnitude is 0, otherwise false
-
isNegative
public boolean isNegative()Check whether the magnitude is of negative value.- Specified by:
isNegativein interfaceMeasurable<BigDecimal,MetricDimension, MetricDimensionUnit> - Returns:
- true if the magnitude is of negative value, otherwise false
-
convertTo
Convert thisMeasurableinto anotherMeasurable.- Specified by:
convertToin interfaceMeasurable<BigDecimal,MetricDimension, MetricDimensionUnit> - Parameters:
unt- TheBaseUnitto convert to- Returns:
- The converted unit
-
add
public Measurable<BigDecimal,MetricDimension, addMetricDimensionUnit> (Measurable<BigDecimal, MetricDimension, MetricDimensionUnit> other) Add anotherMeasurable to this one.- Specified by:
addin interfaceMeasurable<BigDecimal,MetricDimension, MetricDimensionUnit> - Parameters:
other- The one to add- Returns:
- A new instance
-
subtract
public Measurable<BigDecimal,MetricDimension, subtractMetricDimensionUnit> (Measurable<BigDecimal, MetricDimension, MetricDimensionUnit> subtrahent) Subtract anotherMeasurable instance from this one.- Specified by:
subtractin interfaceMeasurable<BigDecimal,MetricDimension, MetricDimensionUnit> - Parameters:
subtrahent- The one to subtract- Returns:
- A new instance
-
compareTo
- Specified by:
compareToin interfaceComparable<MetricDimension>
-
hashCode
public int hashCode()Uses magnitude and unitType for calculation. -
equals
Uses magnitude and unitType for comparison. -
toString
-