Package org.openwms.core.units.api
Class Piece
java.lang.Object
org.openwms.core.units.api.Piece
- All Implemented Interfaces:
Serializable,Comparable<Piece>,Measurable<BigDecimal,Piece, PieceUnit>
A Piece.
- Author:
- Heiko Scherrer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BigDecimalThe magnitude of the Piece.private static final BigDecimalprivate PieceUnitThe unit of the Piece.static final PieceConstant for a zero value.Fields inherited from interface org.openwms.core.units.api.Measurable
SEPARATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPiece()Accessed by persistence provider.privatePiece(BigDecimal magnitude, PieceUnit unitType) Create a new Piece. -
Method Summary
Modifier and TypeMethodDescriptionadd(Measurable<BigDecimal, Piece, PieceUnit> other) Add anotherMeasurable to this one.private intcompare(BigDecimal val1, BigDecimal val2) 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 Pieceof(int magnitude) Create a new Piece.static PieceCreate a new Piece.static Pieceof(BigDecimal magnitude) Create a new Piece.static Pieceof(BigDecimal magnitude, PieceUnit unitType) Create a new Piece.subtract(Measurable<BigDecimal, Piece, PieceUnit> 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
-
SHIFTER
-
unitType
The unit of the Piece. -
magnitude
The magnitude of the Piece. -
ZERO
Constant for a zero value.
-
-
Constructor Details
-
Piece
protected Piece()Accessed by persistence provider. -
Piece
Create a new Piece.- Parameters:
magnitude- The magnitudeunitType- The unit of measure
-
-
Method Details
-
of
Create a new Piece.- Parameters:
magnitude- The magnitudeunitType- The unit of measure- Returns:
- The new instance
-
of
Create a new Piece.- Parameters:
magnitude- The magnitude- Returns:
- The new instance
-
of
Create a new Piece.- Parameters:
magnitude- The magnitudeunitType- The unit of measure- Returns:
- The new instance
-
of
Create a new Piece.- Parameters:
magnitude- The magnitude- Returns:
- The new instance
-
getMagnitude
Get the magnitude of thisMeasurable.- Specified by:
getMagnitudein interfaceMeasurable<BigDecimal,Piece, PieceUnit> - Returns:
- the magnitude
-
getUnitType
Returns the type ofMeasurable.- Specified by:
getUnitTypein interfaceMeasurable<BigDecimal,Piece, PieceUnit> - Returns:
- The
Measurable's type
-
isZero
public boolean isZero()Check whether the magnitude is 0.- Specified by:
isZeroin interfaceMeasurable<BigDecimal,Piece, PieceUnit> - 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,Piece, PieceUnit> - Returns:
- true if the magnitude is of negative value, otherwise false
-
convertTo
Convert thisMeasurableinto anotherMeasurable.- Specified by:
convertToin interfaceMeasurable<BigDecimal,Piece, PieceUnit> - Parameters:
unt- TheBaseUnitto convert to- Returns:
- The converted unit
-
add
Add anotherMeasurable to this one.- Specified by:
addin interfaceMeasurable<BigDecimal,Piece, PieceUnit> - Parameters:
other- The one to add- Returns:
- A new instance
-
toString
-
subtract
public Measurable<BigDecimal,Piece, subtractPieceUnit> (Measurable<BigDecimal, Piece, PieceUnit> subtrahent) Subtract anotherMeasurable instance from this one.- Specified by:
subtractin interfaceMeasurable<BigDecimal,Piece, PieceUnit> - Parameters:
subtrahent- The one to subtract- Returns:
- A new instance
-
compareTo
- Specified by:
compareToin interfaceComparable<Piece>
-
hashCode
public int hashCode()Uses magnitude and unitType for calculation. -
equals
Uses magnitude and unitType for comparison. -
compare
-