Package org.pkl.core

Class DataSize

  • All Implemented Interfaces:
    java.io.Serializable, Value

    public final class DataSize
    extends java.lang.Object
    implements Value
    Java representation of a pkl.base#DataSize value.
    See Also:
    Serialized Form
    • Constructor Detail

      • DataSize

        public DataSize​(double value,
                        DataSizeUnit unit)
        Constructs a new data size with the given value and unit.
    • Method Detail

      • ofBytes

        public static DataSize ofBytes​(double value)
        Constructs a new data size with the given value and unit DataSizeUnit.BYTES.
      • getValue

        public double getValue()
        Returns the value of this data size. The value is relative to the unit and may be negative.
      • getUnit

        public DataSizeUnit getUnit()
        Returns the unit of this data size.
      • inBytes

        public double inBytes()
        Returns the value of this data size measured in DataSizeUnit.BYTES.
      • inKilobytes

        public double inKilobytes()
        Returns the value of this data size measured in DataSizeUnit.KILOBYTES.
      • inKibibytes

        public double inKibibytes()
        Returns the value of this data size measured in DataSizeUnit.KIBIBYTES.
      • inMegabytes

        public double inMegabytes()
        Returns the value of this data size measured in DataSizeUnit.MEGABYTES.
      • inMebibytes

        public double inMebibytes()
        Returns the value of this data size measured in DataSizeUnit.MEBIBYTES.
      • inGigabytes

        public double inGigabytes()
        Returns the value of this data size measured in DataSizeUnit.GIGABYTES.
      • inGibibytes

        public double inGibibytes()
        Returns the value of this data size measured in DataSizeUnit.GIBIBYTES.
      • inTerabytes

        public double inTerabytes()
        Returns the value of this data size measured in DataSizeUnit.TERABYTES.
      • inTebibytes

        public double inTebibytes()
        Returns the value of this data size measured in DataSizeUnit.TEBIBYTES.
      • inPetabytes

        public double inPetabytes()
        Returns the value of this data size measured in DataSizeUnit.PETABYTES.
      • inPebibytes

        public double inPebibytes()
        Returns the value of this data size measured in DataSizeUnit.PEBIBYTES.
      • inWholeBytes

        public long inWholeBytes()
        Returns the value of this data size measured in whole DataSizeUnit.BYTES.
      • inWholeKilobytes

        public long inWholeKilobytes()
        Returns the value of this data size measured in whole DataSizeUnit.KILOBYTES.
      • inWholeKibibytes

        public long inWholeKibibytes()
        Returns the value of this data size measured in whole DataSizeUnit.KIBIBYTES.
      • inWholeMegabytes

        public long inWholeMegabytes()
        Returns the value of this data size measured in whole DataSizeUnit.MEGABYTES.
      • inWholeMebibytes

        public long inWholeMebibytes()
        Returns the value of this data size measured in whole DataSizeUnit.MEBIBYTES.
      • inWholeGigabytes

        public long inWholeGigabytes()
        Returns the value of this data size measured in whole DataSizeUnit.GIGABYTES.
      • inWholeGibibytes

        public long inWholeGibibytes()
        Returns the value of this data size measured in whole DataSizeUnit.GIBIBYTES.
      • inWholeTerabytes

        public long inWholeTerabytes()
        Returns the value of this data size measured in whole DataSizeUnit.TERABYTES.
      • inWholeTebibytes

        public long inWholeTebibytes()
        Returns the value of this data size measured in whole DataSizeUnit.TEBIBYTES.
      • inWholePetabytes

        public long inWholePetabytes()
        Returns the value of this data size measured in whole DataSizeUnit.PETABYTES.
      • inWholePebibytes

        public long inWholePebibytes()
        Returns the value of this data size measured in whole DataSizeUnit.PEBIBYTES.
      • convertTo

        public DataSize convertTo​(DataSizeUnit other)
        Returns a new data size with the given unit and this value converted to the given unit.
      • convertValueTo

        public double convertValueTo​(DataSizeUnit other)
        Returns the value of this data size converted to the given unit.
      • accept

        public void accept​(ValueVisitor visitor)
        Invokes the given visitor's visit method for this Value.
        Specified by:
        accept in interface Value
      • accept

        public <T> T accept​(ValueConverter<T> converter)
        Invokes the given converters's convert method for this Value.
        Specified by:
        accept in interface Value
      • getClassInfo

        public PClassInfo<?> getClassInfo()
        Returns information about the Pkl class associated with this Value.
        Specified by:
        getClassInfo in interface Value
      • equals

        public boolean equals​(@Nullable java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object