Interface ByteSize
- All Superinterfaces:
Comparable<ByteSize>
- All Known Implementing Classes:
ByteSize.Default
public interface ByteSize extends Comparable<ByteSize>
Compound object which carries an amount paired with a
ByteUnit
.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ByteSize.Default
-
Method Summary
Modifier and Type Method Description double
amount()
Gets the amount of thisByteSize
.long
bytes()
static ByteSize
New(double amount, ByteUnit unit)
Pseudo-constructor method which creates a newByteSize
object.static ByteSize
New(String value)
Pseudo-constructor method which creates a newByteSize
object by callingByteSizeParser.parse(String)
.String
toString()
Returns the amount followed by the unit, e.g 1.2MB.ByteUnit
unit()
Gets the unit of thisByteSize
.
-
Method Details
-
amount
double amount()Gets the amount of thisByteSize
.- Returns:
- the amount
-
unit
ByteUnit unit()Gets the unit of thisByteSize
.- Returns:
- the unit
-
bytes
long bytes()- Returns:
- the total number of bytes which
amount()
andunit()
yield - See Also:
ByteUnit.toBytes(double)
-
toString
String toString()Returns the amount followed by the unit, e.g 1.2MB.- Overrides:
toString
in classObject
- Returns:
- a String representation of this byte size, which can be understood by
ByteSizeParser.parse(String)
- See Also:
New(String)
-
New
Pseudo-constructor method which creates a newByteSize
object by callingByteSizeParser.parse(String)
.- Parameters:
value
- the String value wich can be understood byByteSizeParser.parse(String)
- Returns:
- a newly created
ByteSize
object with the given value - See Also:
ByteSizeParser
,ByteSizeParser.parse(String)
-
New
Pseudo-constructor method which creates a newByteSize
object.- Parameters:
amount
- the amountunit
- the unit- Returns:
- a newly created
ByteSize
object with the given values
-