public final class DataSize extends Object implements Comparable<DataSize>
| Modifier and Type | Class and Description |
|---|---|
static class |
DataSize.Unit |
| Constructor and Description |
|---|
DataSize(double size,
DataSize.Unit unit)
Deprecated.
Use
ofBytes(long) instead. The imprecise nature of using doubles for DataSize is deprecated for removal |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(DataSize o) |
DataSize |
convertTo(DataSize.Unit unit)
Deprecated.
Use
to(Unit) instead. No conversion occurs when calling this method, only the unit
used for the default string representation is changed. This has no effect on the unit used during JSON serialization |
DataSize |
convertToMostSuccinctDataSize()
Deprecated.
Use
succinct() instead. No conversion occurs when calling this method, only the unit
used for the default string representation is changed. This has no effect on the unit used during JSON serialization |
boolean |
equals(Object o) |
DataSize.Unit |
getUnit() |
double |
getValue()
Deprecated.
Use
toBytes() instead to avoid floating point precision semantics |
double |
getValue(DataSize.Unit unit)
Deprecated.
Use
toBytes() instead to avoid floating point precision semantics |
int |
hashCode() |
static DataSize |
of(long size,
DataSize.Unit unit)
Creates a
DataSize instance with the provided quantity of the provided DataSize.Unit. |
static DataSize |
ofBytes(long bytes) |
long |
roundTo(DataSize.Unit unit)
Deprecated.
Use
toBytes() instead. This method uses floating point semantics to compute the
rounded value which can yield to unexpected loss of precision beyond the intended rounding |
DataSize |
succinct() |
static DataSize |
succinctBytes(long bytes)
Prefer
ofBytes(long) when conversion to the most 'succinct' unit is not necessary or desirable |
static DataSize |
succinctDataSize(double size,
DataSize.Unit unit)
Deprecated.
use
succinctBytes(long) instead, double values are imprecise |
DataSize |
to(DataSize.Unit unit) |
long |
toBytes() |
String |
toBytesValueString() |
String |
toString() |
static DataSize |
valueOf(String size) |
@Deprecated public DataSize(double size, DataSize.Unit unit)
ofBytes(long) instead. The imprecise nature of using doubles for DataSize is deprecated for removalpublic static DataSize of(long size, DataSize.Unit unit) throws IllegalArgumentException
DataSize instance with the provided quantity of the provided DataSize.Unit. This
value is immediately converted to bytes which might overflow.size - The quantity of the supplied unitunit - The unit to use as the default unit for the constructed instance and to convert the size to bytesIllegalArgumentException - If the provided size would overflow a long value when converting to bytespublic static DataSize ofBytes(long bytes)
public static DataSize succinctBytes(long bytes)
ofBytes(long) when conversion to the most 'succinct' unit is not necessary or desirable@Deprecated public static DataSize succinctDataSize(double size, DataSize.Unit unit)
succinctBytes(long) instead, double values are impreciseof(long, Unit) when conversion to the most 'succinct' unit is not necessary or desirable.
Otherwise, use succinctBytes(long) since it will not incur rounding and loss of precision.public long toBytes()
@Deprecated public double getValue()
toBytes() instead to avoid floating point precision semanticspublic DataSize.Unit getUnit()
@Deprecated public double getValue(DataSize.Unit unit)
toBytes() instead to avoid floating point precision semantics@Deprecated public long roundTo(DataSize.Unit unit)
toBytes() instead. This method uses floating point semantics to compute the
rounded value which can yield to unexpected loss of precision beyond the intended rounding@Deprecated public DataSize convertTo(DataSize.Unit unit)
to(Unit) instead. No conversion occurs when calling this method, only the unit
used for the default string representation is changed. This has no effect on the unit used during JSON serializationpublic DataSize to(DataSize.Unit unit)
public DataSize succinct()
@Deprecated public DataSize convertToMostSuccinctDataSize()
succinct() instead. No conversion occurs when calling this method, only the unit
used for the default string representation is changed. This has no effect on the unit used during JSON serializationpublic String toBytesValueString()
public static DataSize valueOf(String size) throws IllegalArgumentException
IllegalArgumentExceptionpublic int compareTo(DataSize o)
compareTo in interface Comparable<DataSize>Copyright © 2016–2022 Airlift. All rights reserved.