- All Implemented Interfaces:
Serializable
,Comparable<Size.Unit>
,Constable
- Enclosing interface:
Size
Units that can be used.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionBytes.Exabytes (represented aseB
): i.e.Exbi-bytes (represented as eitherEB
orEiB
), where we use binary approach, i.e.Gigabytes (represented asgB
): i.e.Gibi-bytes (represented as eitherGB
orGiB
), where we use binary approach, i.e.Kilobytes (represented askB
), wherekilo
is used in its original meaning as a thousand, i.e.Kibi-bytes (represented as eitherKB
orKiB
), where we use binary approach, i.e.Megabytes (represented asmB
), wheremega
is used in its original meaning as a million, i.e.Mebi-bytes (represented as eitherMB
orMiB
), where we use binary approach, i.e.Petabytes (represented aspB
): i.e.Pebi-bytes (represented as eitherPB
orPiB
), where we use binary approach, i.e.Terabytes (represented astB
): i.e.Tebi-bytes (represented as eitherTB
orTiB
), where we use binary approach, i.e. -
Method Summary
Modifier and TypeMethodDescriptionlong
bytes()
Number of bytes this unit represents.Number of bytes in this unit (exact integer).static Size.Unit
Parse the size string to appropriate unit.static Size.Unit
Returns the enum constant of this class with the specified name.static Size.Unit[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BYTE
Bytes. -
KB
Kilobytes (represented askB
), wherekilo
is used in its original meaning as a thousand, i.e. 1 kB is 1000 bytes. -
KIB
Kibi-bytes (represented as eitherKB
orKiB
), where we use binary approach, i.e. 1 KB or KiB is 1024 bytes. -
MB
Megabytes (represented asmB
), wheremega
is used in its original meaning as a million, i.e. 1 mB is 1000^2 bytes (1000 to the power of 2), or 1000 kB. -
MIB
Mebi-bytes (represented as eitherMB
orMiB
), where we use binary approach, i.e. 1 MB or MiB is 1024^2 bytes (1024 to the power 2), or 1024 KiB. -
GB
Gigabytes (represented asgB
): i.e. 1 gB is 1000^3 bytes (1000 to the power of 3), or 1000 mB. -
GIB
Gibi-bytes (represented as eitherGB
orGiB
), where we use binary approach, i.e. 1 GB or GiB is 1024^3 bytes (1024 to the power 3), or 1024 MiB. -
TB
Terabytes (represented astB
): i.e. 1 gB is 1000^4 bytes (1000 to the power of 4), or 1000 gB. -
TIB
Tebi-bytes (represented as eitherTB
orTiB
), where we use binary approach, i.e. 1 TB or TiB is 1024^4 bytes (1024 to the power 4), or 1024 GiB. -
PB
Petabytes (represented aspB
): i.e. 1 pB is 1000^5 bytes (1000 to the power of 5), or 1000 tB. -
PIB
Pebi-bytes (represented as eitherPB
orPiB
), where we use binary approach, i.e. 1 PB or PiB is 1024^5 bytes (1024 to the power 5), or 1024 TiB. -
EB
Exabytes (represented aseB
): i.e. 1 eB is 1000^6 bytes (1000 to the power of 6), or 1000 pB. -
EIB
Exbi-bytes (represented as eitherEB
orEiB
), where we use binary approach, i.e. 1 EB or EiB is 1024^6 bytes (1024 to the power 6), or 1024 PiB.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
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
-
parse
Parse the size string to appropriate unit.- Parameters:
unitString
- defines the unit, such asKB
,MiB
,pB
etc.; empty string parses toBYTE
- Returns:
- a parsed unit
- Throws:
IllegalArgumentException
- if the unit cannot be parsed
-
bytes
public long bytes()Number of bytes this unit represents.- Returns:
- number of bytes of this unit
-
bytesInteger
Number of bytes in this unit (exact integer).- Returns:
- number of bytes this unit contains
-