Class JsonNumberImpl

    • Constructor Detail

      • JsonNumberImpl

        JsonNumberImpl()
    • Method Detail

      • getJsonNumber

        static JsonNumber getJsonNumber​(int num)
      • getJsonNumber

        static JsonNumber getJsonNumber​(long num)
      • getJsonNumber

        static JsonNumber getJsonNumber​(java.math.BigInteger value)
      • getJsonNumber

        static JsonNumber getJsonNumber​(double value)
      • getJsonNumber

        static JsonNumber getJsonNumber​(java.math.BigDecimal value)
      • isIntegral

        public boolean isIntegral()
        Description copied from interface: JsonNumber
        Returns true if this JSON number is a integral number. This method semantics are defined using bigDecimalValue().scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example:
         
         JsonNumber num = ...
         if (num.isIntegral()) {
             num.longValue();     // or other methods to get integral value
         } else {
             num.doubleValue();   // or other methods to get decimal number value
         }
         
         
        Specified by:
        isIntegral in interface JsonNumber
        Returns:
        true if this number is a integral number, otherwise false
      • intValue

        public int intValue()
        Description copied from interface: JsonNumber
        Returns this JSON number as an int. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.
        Specified by:
        intValue in interface JsonNumber
        Returns:
        an int representation of the JSON number
        See Also:
        BigDecimal.intValue()
      • intValueExact

        public int intValueExact()
        Description copied from interface: JsonNumber
        Returns this JSON number as an int.
        Specified by:
        intValueExact in interface JsonNumber
        Returns:
        an int representation of the JSON number
        See Also:
        BigDecimal.intValueExact()
      • longValue

        public long longValue()
        Description copied from interface: JsonNumber
        Returns this JSON number as a long. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.
        Specified by:
        longValue in interface JsonNumber
        Returns:
        a long representation of the JSON number.
        See Also:
        BigDecimal.longValue()
      • longValueExact

        public long longValueExact()
        Description copied from interface: JsonNumber
        Returns this JSON number as a long.
        Specified by:
        longValueExact in interface JsonNumber
        Returns:
        a long representation of the JSON number
        See Also:
        BigDecimal.longValueExact()
      • doubleValue

        public double doubleValue()
        Description copied from interface: JsonNumber
        Returns this JSON number as a double. This is a a convenience method for bigDecimalValue().doubleValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.
        Specified by:
        doubleValue in interface JsonNumber
        Returns:
        a double representation of the JSON number
        See Also:
        BigDecimal.doubleValue()
      • bigIntegerValue

        public java.math.BigInteger bigIntegerValue()
        Description copied from interface: JsonNumber
        Returns this JSON number as a BigInteger object. This is a a convenience method for bigDecimalValue().toBigInteger(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.
        Specified by:
        bigIntegerValue in interface JsonNumber
        Returns:
        a BigInteger representation of the JSON number.
        See Also:
        BigDecimal.toBigInteger()
      • bigIntegerValueExact

        public java.math.BigInteger bigIntegerValueExact()
        Description copied from interface: JsonNumber
        Returns this JSON number as a BigInteger object. This is a convenience method for bigDecimalValue().toBigIntegerExact().
        Specified by:
        bigIntegerValueExact in interface JsonNumber
        Returns:
        a BigInteger representation of the JSON number
        See Also:
        BigDecimal.toBigIntegerExact()
      • hashCode

        public int hashCode()
        Description copied from interface: JsonNumber
        Returns the hash code value for this JsonNumber object. The hash code of a JsonNumber object is defined as the hash code of its JsonNumber.bigDecimalValue() object.
        Specified by:
        hashCode in interface JsonNumber
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code value for this JsonNumber object
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: JsonNumber
        Compares the specified object with this JsonNumber object for equality. Returns true if and only if the type of the specified object is also JsonNumber and their JsonNumber.bigDecimalValue() objects are equal
        Specified by:
        equals in interface JsonNumber
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to be compared for equality with this JsonNumber
        Returns:
        true if the specified object is equal to this JsonNumber
      • toString

        public java.lang.String toString()
        Description copied from interface: JsonNumber
        Returns a JSON text representation of the JSON number. The representation is equivalent to BigDecimal.toString().
        Specified by:
        toString in interface JsonNumber
        Specified by:
        toString in interface JsonValue
        Overrides:
        toString in class java.lang.Object
        Returns:
        JSON text representation of the number