Package org.ehcache.config.units
Enum MemoryUnit
- java.lang.Object
-
- java.lang.Enum<MemoryUnit>
-
- org.ehcache.config.units.MemoryUnit
-
- All Implemented Interfaces:
Serializable,Comparable<MemoryUnit>,ResourceUnit
public enum MemoryUnit extends Enum<MemoryUnit> implements ResourceUnit
AResourceUnitthat designates memory quantity.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(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.StringtoString()static MemoryUnitvalueOf(String name)Returns 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 Detail
-
B
public static final MemoryUnit B
Bytes.
-
KB
public static final MemoryUnit KB
Kilobytes.
-
MB
public static final MemoryUnit MB
Megabytes.
-
GB
public static final MemoryUnit GB
Gigabytes.
-
TB
public static final MemoryUnit TB
Terabytes.
-
PB
public static final MemoryUnit PB
Petabytes.
-
-
Method Detail
-
values
public static MemoryUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MemoryUnit c : MemoryUnit.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MemoryUnit valueOf(String name)
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
-
toBytes
public long toBytes(long quantity)
Convertsquantityin this unit to bytes.- Parameters:
quantity- the quantity- Returns:
- the quantity in bytes
-
convert
public long convert(long quantity, MemoryUnit unit)Convertsquantityinunitinto this unit.- Parameters:
quantity- quantity to convertunit-quantity's unit- Returns:
- the quantity in this unit
-
toString
public String toString()
- Overrides:
toStringin classEnum<MemoryUnit>
-
compareTo
public int compareTo(long thisSize, long thatSize, ResourceUnit thatUnit) throws IllegalArgumentExceptionComparesthisSizein 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
-
-