Enum Class DataSize
- All Implemented Interfaces:
Serializable, Comparable<DataSize>, Constable, Dimension, DimensionWithLinearConversion
@ClassVersion(sourceVersion="$Id: DataSize.java 1195 2026-04-15 21:33:40Z tquadrat $")
@API(status=STABLE,
since="0.1.0")
public enum DataSize
extends Enum<DataSize>
implements DimensionWithLinearConversion
The various instances of data sizes (for files or free disk space or
capacities of memory sticks …).
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: DataSize.java 1195 2026-04-15 21:33:40Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.value.DataSize"
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA single byte.A gigabyte in the binary form.A gigabyte (the decimal form).A Kilobyte with 1024 bytes.A Kilobyte (with 1000 bytes).A megabyte in the binary form.A megabyte (the decimal form).A terabyte in the binary form.A terabyte (the decimal form). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BigDecimalThe factor.private final intThe default precision.private final StringThe unit string.Fields inherited from interface DimensionWithLinearConversion
MSG_UnknownUnit -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDataSize(BigDecimal factor, String unitSymbol) Creates a newDataSizeinstance, with a default precision of zero mantissa digits.privateDataSize(BigDecimal factor, String unitSymbol, int precision) Creates a newDataSizeinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal DataSizebaseUnit()final BigDecimalfactor()static final DataSizeReturns theDataSizeinstance for the given unit.final intfinal Stringstatic DataSizeReturns the enum constant of this class with the specified name.static DataSize[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface Dimension
equals, name, toString, unitSymbolForPrintingMethods inherited from interface DimensionWithLinearConversion
fromBase, toBase
-
Enum Constant Details
-
BYTE
-
KILOBYTE
-
KIBIBYTE
-
MEGABYTE
-
MEBIBYTE
-
GIGABYTE
-
GIBIBYTE
-
TERABYTE
-
TEBIBYTE
-
-
Field Details
-
m_Factor
The factor. -
m_Precision
The default precision. -
m_UnitSymbol
The unit string.
-
-
Constructor Details
-
DataSize
Creates a newDataSizeinstance.- Parameters:
factor- The factor.unitSymbol- The unit string.precision- The default precision.
-
DataSize
Creates a newDataSizeinstance, with a default precision of zero mantissa digits.- Parameters:
factor- The factor.unitSymbol- The unit string.
-
-
Method Details
-
values
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
baseUnit
-
factor
- Specified by:
factorin interfaceDimensionWithLinearConversion
-
forUnit
Returns theDataSizeinstance for the given unit.- Parameters:
unit- The unit.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
getPrecision
- Specified by:
getPrecisionin interfaceDimension
-
unitSymbol
- Specified by:
unitSymbolin interfaceDimension
-
