Class DataSize

    • Constructor Detail

      • DataSize

        @Deprecated
        public DataSize​(double size,
                        DataSize.Unit unit)
        Deprecated.
        Use ofBytes(long) instead. The imprecise nature of using doubles for DataSize is deprecated for removal
    • Method Detail

      • of

        public static DataSize of​(long size,
                                  DataSize.Unit unit)
                           throws IllegalArgumentException
        Creates a DataSize instance with the provided quantity of the provided DataSize.Unit. This value is immediately converted to bytes which might overflow.
        Parameters:
        size - The quantity of the supplied unit
        unit - The unit to use as the default unit for the constructed instance and to convert the size to bytes
        Throws:
        IllegalArgumentException - If the provided size would overflow a long value when converting to bytes
      • ofBytes

        public static DataSize ofBytes​(long bytes)
      • succinctBytes

        public static DataSize succinctBytes​(long bytes)
        Prefer ofBytes(long) when conversion to the most 'succinct' unit is not necessary or desirable
      • toBytes

        public long toBytes()
      • getValue

        @Deprecated
        public double getValue()
        Deprecated.
        Use toBytes() instead to avoid floating point precision semantics
      • roundTo

        @Deprecated
        public 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
      • convertTo

        @Deprecated
        public 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
      • convertToMostSuccinctDataSize

        @Deprecated
        public 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
      • toBytesValueString

        public String toBytesValueString()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object