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 classByteSize.Default -
Method Summary
Modifier and Type Method Description doubleamount()Gets the amount of thisByteSize.longbytes()static ByteSizeNew(double amount, ByteUnit unit)Pseudo-constructor method which creates a newByteSizeobject.static ByteSizeNew(String value)Pseudo-constructor method which creates a newByteSizeobject by callingByteSizeParser.parse(String).StringtoString()Returns the amount followed by the unit, e.g 1.2MB.ByteUnitunit()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:
toStringin 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 newByteSizeobject by callingByteSizeParser.parse(String).- Parameters:
value- the String value wich can be understood byByteSizeParser.parse(String)- Returns:
- a newly created
ByteSizeobject with the given value - See Also:
ByteSizeParser,ByteSizeParser.parse(String)
-
New
Pseudo-constructor method which creates a newByteSizeobject.- Parameters:
amount- the amountunit- the unit- Returns:
- a newly created
ByteSizeobject with the given values
-