Package org.djunits.unit
Class Unit.Builder<U extends Unit<U>>
java.lang.Object
org.djunits.unit.Unit.Builder<U>
- Type Parameters:
U
- the unit for which the builder contains the information.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbsoluteLinearUnit.Builder
The class that contains the information to build a unit.
Copyright (c) 2019-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Author:
- Alexander Verbraeck
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRetrieve the additional abbreviations.Retrieve the default display abbreviation.Retrieve the default textual abbreviation.getId()
Retrieve the id of the unit that this builder builds.getName()
Return the name.Retrieve the unit base.getScale()
Retrieve the scale.Return whether SI prefixes, ranging from yotta (y) to yocto (Y), will be generated.double
Return the power factor of the SI prefixes, e.g. 2.0 for square meters and 3.0 for cubic meters.Retrieve the unit system.boolean
Retrieve the generated flag.setAdditionalAbbreviations
(String... newAdditionalAbbreviations) Set the additional abbreviations.setDefaultDisplayAbbreviation
(String newDefaultDisplayAbbreviation) Set the default display abbreviation.setDefaultTextualAbbreviation
(String newDefaultTextualAbbreviation) Set the default textual abbreviation.setGenerated
(boolean newGenerated) Set the generated flag.Set the id of the unit that this builder builds.Set the name.setQuantity
(Quantity<U> newQuantity) Set the unit base.Set the scale.setSiPrefixes
(SIPrefixes newSiPrefixes, double power) Set whether SI prefixes, ranging from yotta (y) to yocto (Y), are allowed.setUnitSystem
(UnitSystem newUnitSystem) Set the unit system.toString()
-
Constructor Details
-
Builder
public Builder()Empty constructor. Content is generated through chaining: new Unit.Builder<TypeUnit>().setId("id").setName("name");
-
-
Method Details
-
getSiPrefixes
Return whether SI prefixes, ranging from yotta (y) to yocto (Y), will be generated.- Returns:
- siPrefixes, NONE (e.g., for inch), ALL (e.g., for meter) or KILO (e.g., for kilometer)
-
getSiPrefixPowerFactor
public double getSiPrefixPowerFactor()Return the power factor of the SI prefixes, e.g. 2.0 for square meters and 3.0 for cubic meters.- Returns:
- siPrefixPower double; power factor of the SI prefixes, e.g. 2.0 for square meters and 3.0 for cubic meters
-
setSiPrefixes
Set whether SI prefixes, ranging from yotta (y) to yocto (Y), are allowed. If not set; this property defaults tofalse
.- Parameters:
newSiPrefixes
- SIPrefixes; SIPrefixes set siPrefixes, NONE (e.g., for inch), ALL (e.g., for meter) or KILO (e.g., for kilometer)power
- double; power factor of the SI prefixes, e.g. 2.0 for square meters and 3.0 for cubic meters- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
getId
Retrieve the id of the unit that this builder builds.- Returns:
- String; the id of the unit that this builder builds
-
setId
Set the id of the unit that this builder builds.- Parameters:
newId
- String; set the id of the unit that this builder builds (must be set; the default isnull
which is invalid)- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
getAdditionalAbbreviations
Retrieve the additional abbreviations.- Returns:
- Set<String>; the additional abbreviations
-
setAdditionalAbbreviations
Set the additional abbreviations.- Parameters:
newAdditionalAbbreviations
- String...; the additional abbreviations- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
getDefaultDisplayAbbreviation
Retrieve the default display abbreviation.- Returns:
- String; the default display abbreviation
-
setDefaultDisplayAbbreviation
Set the default display abbreviation.- Parameters:
newDefaultDisplayAbbreviation
- String; the default display abbreviation- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
getDefaultTextualAbbreviation
Retrieve the default textual abbreviation.- Returns:
- String; the default textual abbreviation
-
setDefaultTextualAbbreviation
Set the default textual abbreviation.- Parameters:
newDefaultTextualAbbreviation
- String; the default textual abbreviation- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
getName
Return the name.- Returns:
- String; the name
-
setName
Set the name.- Parameters:
newName
- String; the name- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
getScale
Retrieve the scale.- Returns:
- Scale; the scale
-
setScale
Set the scale.- Parameters:
newScale
- Scale; set the scale- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
getUnitSystem
Retrieve the unit system.- Returns:
- unitSystem UnitSystem; the unit system
-
setUnitSystem
Set the unit system.- Parameters:
newUnitSystem
- UnitSystem; the unit system- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
isGenerated
public boolean isGenerated()Retrieve the generated flag.- Returns:
- generated Boolean; the generated flag
-
setGenerated
Set the generated flag. Defaults to false. Should be set for units that are automatically generated.- Parameters:
newGenerated
- boolean; the value for the generated flag- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
getQuantity
Retrieve the unit base.- Returns:
- baseUnit BaseUnit<U>; the unit base
-
setQuantity
Set the unit base. Can never be null and has to be filled.- Parameters:
newQuantity
- Quantity<U>; the unit base- Returns:
- Builder; this builder instance that is being constructed (for method call chaining)
-
toString
-