Package com.couchbase.client.core.util
Class StorageSize
java.lang.Object
com.couchbase.client.core.util.StorageSize
A size measured in bytes, kibibytes, mebibytes, etc.
Create an instance using one of the "of" factory methods,
or from a string using parse(String).
-
Method Summary
Modifier and TypeMethodDescriptionlongbytes()Returns the storage size in bytes.intReturns the storage size in bytes.booleanformat()inthashCode()static StorageSizeofBytes(long value) static StorageSizeofGibibytes(long value) static StorageSizeofKibibytes(long value) static StorageSizeofMebibytes(long value) static StorageSizeofPebibytes(long value) static StorageSizeofTebibytes(long value) static StorageSizeCreates a new instance from its string representation: a whole number followed by a unit, optionally separated by whitespace.toString()
-
Method Details
-
parse
Creates a new instance from its string representation: a whole number followed by a unit, optionally separated by whitespace. Recognized units: B, KiB, MiB, GiB, TiB, PiB.Examples:
- "128B" or "128 B" -> 128 bytes
- "512KiB" or "512 KiB" -> 512 kibibytes
- "64MiB" or "64 MiB" -> 64 mebibytes
- etc.
- Throws:
IllegalArgumentException- if the given string could not be parsed
-
ofBytes
- Throws:
IllegalArgumentException- if value is negative
-
ofKibibytes
- Throws:
IllegalArgumentException- if value is negative, or the size is greater thanLong.MAX_VALUEbytes (~8191 PiB)
-
ofMebibytes
- Throws:
IllegalArgumentException- if value is negative, or the size is greater thanLong.MAX_VALUEbytes (~8191 PiB)
-
ofGibibytes
- Throws:
IllegalArgumentException- if value is negative, or the size is greater thanLong.MAX_VALUEbytes (~8191 PiB)
-
ofTebibytes
- Throws:
IllegalArgumentException- if value is negative, or the size is greater thanLong.MAX_VALUEbytes (~8191 PiB)
-
ofPebibytes
- Throws:
IllegalArgumentException- if value is negative, or the size is greater thanLong.MAX_VALUEbytes (~8191 PiB)
-
bytes
public long bytes()Returns the storage size in bytes. -
bytesAsInt
public int bytesAsInt()Returns the storage size in bytes.- Throws:
IllegalArgumentException- if this size is >= 2 GiB
-
requireInt
-
format
-
toString
-
equals
-
hashCode
public int hashCode()
-