Package org.ehcache.config.units
Enum Class MemoryUnit
- All Implemented Interfaces:
Serializable,Comparable<MemoryUnit>,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 -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(long thisSize, long thatSize, ResourceUnit thatUnit) ComparesthisSizein this unit tothatSizeinthatUnit.longconvert(long quantity, MemoryUnit unit) Convertsquantityinunitinto this unit.longtoBytes(long quantity) Convertsquantityin this unit to bytes.toString()static MemoryUnitReturns the enum constant of this class with the specified name.static MemoryUnit[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
B
Bytes. -
KB
Kilobytes. -
MB
Megabytes. -
GB
Gigabytes. -
TB
Terabytes. -
PB
Petabytes.
-
-
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
-
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
-