Package org.ehcache.config.units
Enum MemoryUnit
- All Implemented Interfaces:
Serializable,Comparable<MemoryUnit>,java.lang.constant.Constable,ResourceUnit
A
ResourceUnit that designates memory quantity.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateMemoryUnit(String stringForm, int index) Internal constructor -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(long thisSize, long thatSize, ResourceUnit thatUnit) ComparesthisSizein this unit tothatSizeinthatUnit.longconvert(long quantity, MemoryUnit unit) Convertsquantityinunitinto this unit.private static longdoConvert(int delta, long amount) ComputeslongtoBytes(long quantity) Convertsquantityin this unit to bytes.toString()static MemoryUnitReturns the enum constant of this type with the specified name.static MemoryUnit[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
B
Bytes. -
KB
Kilobytes. -
MB
Megabytes. -
GB
Gigabytes. -
TB
Terabytes. -
PB
Petabytes.
-
-
Field Details
-
index
private final int indexthe index of this unit -
stringForm
-
-
Constructor Details
-
MemoryUnit
Internal constructor
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
doConvert
Computesamount * 2^delta
. The result is always rounded toward zero.- Parameters:
delta- log2(divisor)amount- dividend- Throws:
ArithmeticException- if the result overflows
-
toBytes
public long toBytes(long quantity) Convertsquantityin this unit to bytes.- Parameters:
quantity- the quantity- Returns:
- the quantity in bytes
-
convert
Convertsquantityinunitinto this unit.- Parameters:
quantity- quantity to convertunit-quantity's unit- Returns:
- the quantity in this unit
-
toString
- Overrides:
toStringin classEnum<MemoryUnit>
-
compareTo
public int compareTo(long thisSize, long thatSize, ResourceUnit thatUnit) throws IllegalArgumentException ComparesthisSizein this unit tothatSizeinthatUnit.Returns 1, 0, or -1 if the
thisSizeofthisis greater than, equal to, or less thanthatSizeofthatUnitrespectively.- Specified by:
compareToin interfaceResourceUnit- Parameters:
thisSize- size in this unitthatSize- size inthatUnitthatUnit- otherResourceUnit- Returns:
- as per the
compareTocontract - Throws:
IllegalArgumentException- if the units are not comparable
-