Class Quantity

    • Constructor Detail

      • Quantity

        public Quantity()
        No args constructor for use in serialization
      • Quantity

        public Quantity​(String amount)
        Single argument constructor for setting amount.
        Parameters:
        amount - amount of quantity specified.
      • Quantity

        public Quantity​(String amount,
                        String format)
        Double argument constructor for setting amount along with format.
        Parameters:
        amount - amount of quantity specified
        format - format for the amount.
    • Method Detail

      • getAmount

        public String getAmount()
      • setAmount

        public void setAmount​(String amount)
      • getFormat

        public String getFormat()
      • setFormat

        public void setFormat​(String format)
      • getNumericalAmount

        public BigDecimal getNumericalAmount()
                                      throws ArithmeticException
        If this is a memory Quantity, the result will represent bytes.
        If this is a cpu Quantity, the result will represent cores.
        Returns:
        the formatted amount as a number
        Throws:
        ArithmeticException
      • fromNumericalAmount

        public static Quantity fromNumericalAmount​(BigDecimal amountInBytes,
                                                   String desiredFormat)
        Constructs a new Quantity from the provided amountInBytes. This amount is converted to a value with the unit provided in desiredFormat.
        Parameters:
        amountInBytes -
        desiredFormat -
        Returns:
        a new Quantity with the value of amountInBytes with units desiredFormat
        See Also:
        getNumericalAmount()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getAdditionalProperties

        public Map<String,​Object> getAdditionalProperties()
      • setAdditionalProperty

        public void setAdditionalProperty​(String name,
                                          Object value)
      • add

        public Quantity add​(Quantity y)
        Add the provided quantity to the current value. If the current value is zero, the format of the quantity will be the format of y.
        Parameters:
        y - to add
        Returns:
        a new Quantity after y has been added
      • subtract

        public Quantity subtract​(Quantity y)
        Subtract the provided quantity from the current value. If the current value is zero, the format of the quantity will be the format of y.
        Parameters:
        y - to subtract
        Returns:
        a new Quantity after y has been subtracted
      • multiply

        public Quantity multiply​(int multiplicand)
        Multiplies the quantity by the specified scalar multiplicand.
        Parameters:
        multiplicand - the scalar value to multiply by
        Returns:
        a new Quantity resulting from the multiplication of this quantity by the scalar multiplicand