public enum SizeUnit extends Enum<SizeUnit>
SizeUnit represents digital information size at a given
unit of granularity and provides utility methods to convert across
the units.| Enum Constant and Description |
|---|
BYTES
Byte (B), 1 Byte.
|
GIGABYTES
Gigabyte (GB),
2^30 Byte = 1.024 * 1.024 * 1.024 Byte = 1.073.741.824 Byte.
|
KILOBYTES
Kilobyte (kB), 2^10 Byte = 1.024 Byte.
|
MEGABYTES
Megabyte (MB), 2^20 Byte = 1.024 * 1.024 Byte = 1.048.576 Byte.
|
PETABYTES
Petabyte (PB),
2^50 Byte = 1.024 * 1.024 * 1.024 * 1.024 * 1.024 Byte = 1.125.899.906.842.624 Byte.
|
TERABYTES
Terabyte (TB),
2^40 Byte = 1.024 * 1.024 * 1.024 * 1.024 Byte = 1.099.511.627.776 Byte.
|
| Modifier and Type | Method and Description |
|---|---|
long |
convert(long source,
SizeUnit sourceUnit)
Converts a
source value with a specified SizeUnit to that instance. |
long |
toBytes(long value)
Translates a value to bytes.
|
long |
toGigabytes(long value)
Translates a value to gigabytes.
|
long |
toKilobytes(long value)
Translates a value to kilobytes.
|
long |
toMegabytes(long value)
Translates a value to megabytes.
|
long |
toPetabytes(long value)
Translates a value to petabytes.
|
long |
toTerabytes(long value)
Translates a value to terabytes.
|
static SizeUnit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SizeUnit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SizeUnit BYTES
public static final SizeUnit KILOBYTES
public static final SizeUnit MEGABYTES
public static final SizeUnit GIGABYTES
public static final SizeUnit TERABYTES
public static final SizeUnit PETABYTES
public static SizeUnit[] values()
for (SizeUnit c : SizeUnit.values()) System.out.println(c);
public static SizeUnit valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic long convert(long source,
SizeUnit sourceUnit)
source value with a specified SizeUnit to that instance.source - the value to convert.sourceUnit - the value's size unit.public long toBytes(long value)
value - the value to convert.public long toKilobytes(long value)
value - the value to convert.public long toMegabytes(long value)
value - the value to convert.public long toGigabytes(long value)
value - the value to convert.public long toTerabytes(long value)
value - the value to convert.public long toPetabytes(long value)
value - the value to convert.Copyright © 2019–2020 Appulse. All rights reserved.