Package ai.dat.core.configuration
Class MemorySize
java.lang.Object
ai.dat.core.configuration.MemorySize
- All Implemented Interfaces:
Serializable,Comparable<MemorySize>
MemorySize is a representation of a number of bytes, viewable in different units.
Parsing
The size can be parsed from a text expression. If the expression is a pure number, the value will be interpreted as bytes.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum which defines memory unit, mostly used to parse value from configuration file. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(MemorySize that) intcompareTo(MemorySize that) divide(long by) booleanlongGets the memory size in Gibibytes (= 1024 Mebibytes).longGets the memory size in Kibibytes (= 1024 bytes).intGets the memory size in Mebibytes (= 1024 Kibibytes).longGets the memory size in Tebibytes (= 1024 Gibibytes).inthashCode()multiply(double multiplier) static MemorySizeofMebiBytes(long mebiBytes) static MemorySizeParses the given string as as MemorySize.static MemorySizeparse(String text, MemorySize.MemoryUnit defaultUnit) Parses the given string with a default unit.static longparseBytes(String text) Parses the given string as bytes.subtract(MemorySize that) toString()
-
Field Details
-
ZERO
-
MAX_VALUE
-
-
Constructor Details
-
MemorySize
public MemorySize(long bytes) Constructs a new MemorySize.- Parameters:
bytes- The size, in bytes. Must be zero or larger.
-
-
Method Details
-
ofMebiBytes
-
getKibiBytes
public long getKibiBytes()Gets the memory size in Kibibytes (= 1024 bytes). -
getMebiBytes
public int getMebiBytes()Gets the memory size in Mebibytes (= 1024 Kibibytes). -
getGibiBytes
public long getGibiBytes()Gets the memory size in Gibibytes (= 1024 Mebibytes). -
getTebiBytes
public long getTebiBytes()Gets the memory size in Tebibytes (= 1024 Gibibytes). -
hashCode
public int hashCode() -
equals
-
toString
-
toHumanReadableString
-
compareTo
- Specified by:
compareToin interfaceComparable<MemorySize>
-
add
-
subtract
-
multiply
-
divide
-
parse
Parses the given string as as MemorySize.- Parameters:
text- The string to parse- Returns:
- The parsed MemorySize
- Throws:
IllegalArgumentException- Thrown, if the expression cannot be parsed.
-
parse
public static MemorySize parse(String text, MemorySize.MemoryUnit defaultUnit) throws IllegalArgumentException Parses the given string with a default unit.- Parameters:
text- The string to parse.defaultUnit- specify the default unit.- Returns:
- The parsed MemorySize.
- Throws:
IllegalArgumentException- Thrown, if the expression cannot be parsed.
-
parseBytes
Parses the given string as bytes. The supported expressions are listed underMemorySize.- Parameters:
text- The string to parse- Returns:
- The parsed size, in bytes.
- Throws:
IllegalArgumentException- Thrown, if the expression cannot be parsed.
-