public final class Quantity extends Object
This class is thread-safe.
Constructor and Description |
---|
Quantity(String name,
String description)
Create a new quantity instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addUnit(Unit unit,
boolean isBaseUnit)
Associate the specified unit with this quantity.
|
Unit |
getBaseUnit()
Return the base unit of this quantity.
|
String |
getDescription()
Return description of this quantity.
|
String |
getName()
Return name of this quantity.
|
List<Unit> |
getUnits()
Return the units of this quantity.
|
String |
toString() |
public Quantity(String name, String description)
name
- Name of quantity, such as "length". Non-null.description
- Optional description. Null if none provided.IllegalArgumentException
- If name is null.public String getName()
public String getDescription()
public List<Unit> getUnits()
public Unit getBaseUnit()
public void addUnit(Unit unit, boolean isBaseUnit)
unit
- Unit to add. Non-null.isBaseUnit
- True if this is the base unit, false otherwise.
If more than one unit is added as base unit, the
last one added will have this role. If no units are
added as base unit, the first unit added will have
this role.IllegalArgumentException
- If unit is null.Copyright © 2020 Petroware AS - https://petroware.no