Package tech.units.indriya.unit
Enum MetricPrefix
- java.lang.Object
-
- java.lang.Enum<MetricPrefix>
-
- tech.units.indriya.unit.MetricPrefix
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<MetricPrefix>
,Prefix
public enum MetricPrefix extends java.lang.Enum<MetricPrefix> implements Prefix
This class provides support for the 20 prefixes used in the metric system (decimal multiples and submultiples of units). For example:
import static tech.units.indriya.unit.Units.*; // Static import. import static tech.units.indriya.unit.MetricPrefix.*; // Static import. import javax.measure.*; import javax.measure.quantity.*; ... Unit
HECTOPASCAL = HECTO(PASCAL); Unit KILOMETRE = KILO(METRE); - Since:
- 2.0
- Version:
- 1.8, 2018-04-20
- See Also:
- Wikipedia: Metric Prefix
-
-
Field Summary
Fields Modifier and Type Field Description private int
base
Base part of the associated factor in base^exponent representation.private int
exponent
Exponent part of the associated factor in base^exponent representation.private java.lang.String
symbol
The symbol of this prefix, as returned bygetSymbol()
.
-
Constructor Summary
Constructors Modifier Constructor Description private
MetricPrefix(java.lang.String symbol, int base, int exponent)
Creates a new prefix.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>ATTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-18
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>CENTI(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-2
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>DECI(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-1
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>DEKA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor101
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>EXA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1018
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>FEMTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-15
int
getBase()
Base part of the associated factor in base^exponent representation.int
getExponent()
Exponent part of the associated factor in base^exponent representation.java.lang.String
getSymbol()
Returns the symbol of this prefix.static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>GIGA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor109
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>HECTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor102
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>KILO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor103
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>MEGA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor106
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>MICRO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-6
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>MILLI(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-3
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>NANO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-9
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>PETA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1015
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>PICO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-12
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>TERA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1012
static MetricPrefix
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static MetricPrefix[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>YOCTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-24
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>YOTTA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1024
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>ZEPTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-21
static <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>ZETTA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1021
-
-
-
Enum Constant Detail
-
YOTTA
public static final MetricPrefix YOTTA
-
ZETTA
public static final MetricPrefix ZETTA
-
EXA
public static final MetricPrefix EXA
-
PETA
public static final MetricPrefix PETA
-
TERA
public static final MetricPrefix TERA
-
GIGA
public static final MetricPrefix GIGA
-
MEGA
public static final MetricPrefix MEGA
-
KILO
public static final MetricPrefix KILO
-
HECTO
public static final MetricPrefix HECTO
-
DEKA
public static final MetricPrefix DEKA
-
DECI
public static final MetricPrefix DECI
-
CENTI
public static final MetricPrefix CENTI
-
MILLI
public static final MetricPrefix MILLI
-
MICRO
public static final MetricPrefix MICRO
-
NANO
public static final MetricPrefix NANO
-
PICO
public static final MetricPrefix PICO
-
FEMTO
public static final MetricPrefix FEMTO
-
ATTO
public static final MetricPrefix ATTO
-
ZEPTO
public static final MetricPrefix ZEPTO
-
YOCTO
public static final MetricPrefix YOCTO
-
-
Field Detail
-
symbol
private final java.lang.String symbol
The symbol of this prefix, as returned bygetSymbol()
.- See Also:
getSymbol()
-
base
private int base
Base part of the associated factor in base^exponent representation.
-
exponent
private int exponent
Exponent part of the associated factor in base^exponent representation.
-
-
Constructor Detail
-
MetricPrefix
private MetricPrefix(java.lang.String symbol, int base, int exponent)
Creates a new prefix.- Parameters:
symbol
- the symbol of this prefix.base
- part of the associated factor in base^exponent representation.exponent
- part of the associated factor in base^exponent representation.
-
-
Method Detail
-
values
public static MetricPrefix[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MetricPrefix c : MetricPrefix.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MetricPrefix valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
YOTTA
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> YOTTA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1024
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e24)
.
-
ZETTA
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> ZETTA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1021
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e21)
.
-
EXA
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> EXA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1018
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e18)
.
-
PETA
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> PETA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1015
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e15)
.
-
TERA
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> TERA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor1012
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e12)
.
-
GIGA
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> GIGA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor109
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e9)
.
-
MEGA
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> MEGA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor106
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e6)
.
-
KILO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> KILO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor103
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e3)
.
-
HECTO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> HECTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor102
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e2)
.
-
DEKA
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> DEKA(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor101
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e1)
.
-
DECI
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> DECI(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-1
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-1)
.
-
CENTI
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> CENTI(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-2
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-2)
.
-
MILLI
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> MILLI(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-3
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-3)
.
-
MICRO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> MICRO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-6
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-6)
.
-
NANO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> NANO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-9
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-9)
.
-
PICO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> PICO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-12
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-12)
.
-
FEMTO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> FEMTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-15
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-15)
.
-
ATTO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> ATTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-18
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-18)
.
-
ZEPTO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> ZEPTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-21
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-21)
.
-
YOCTO
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> YOCTO(javax.measure.Unit<Q> unit)
Returns the specified unit multiplied by the factor10-24
- Type Parameters:
Q
- The type of the quantity measured by the unit.- Parameters:
unit
- any unit.- Returns:
unit.times(1e-24)
.
-
getSymbol
public java.lang.String getSymbol()
Returns the symbol of this prefix.
-
getBase
public int getBase()
Base part of the associated factor in base^exponent representation.
-
getExponent
public int getExponent()
Exponent part of the associated factor in base^exponent representation.- Specified by:
getExponent
in interfacePrefix
-
-