Class JsonNumber

    • Constructor Detail

      • JsonNumber

        public JsonNumber​(java.math.BigDecimal number)
        Creates new JSON number from given BigDecimal.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(java.math.BigInteger number)
        Creates new JSON number from given BigInteger.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(byte number)
        Creates new JSON number from given byte.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(double number)
        Creates new JSON number from given double.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(java.time.Duration number)
        Creates new JSON number from given Duration.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(float number)
        Creates new JSON number from given float.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(int number)
        Creates new JSON number from given int.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(java.time.Instant number)
        Creates new JSON number from given Instant.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(long number)
        Creates new JSON number from given long.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(java.time.OffsetDateTime number)
        Creates new JSON number from given OffsetDateTime.
        Parameters:
        number - Number.
      • JsonNumber

        public JsonNumber​(short number)
        Creates new JSON number from given short.
        Parameters:
        number - Number.
    • Method Detail

      • toBigDecimal

        public java.math.BigDecimal toBigDecimal()
        Returns:
        This number converted to a BigDecimal.
      • toBigInteger

        public java.math.BigInteger toBigInteger()
        Returns:
        This number converted to a BigInteger.
        Throws:
        java.lang.NumberFormatException - If this number contains decimals or uses exponent notation.
      • toByte

        public byte toByte()
        Returns:
        This number converted to a byte.
        Throws:
        java.lang.NumberFormatException - If this number contains decimals, uses exponent notation or is too large.
      • toDouble

        public double toDouble()
        Returns:
        This number converted to a double.
      • toDuration

        public java.time.Duration toDuration()
        Returns:
        This number converted to a Duration.
        Throws:
        java.lang.ArithmeticException - If this number is too large.
      • toFloat

        public float toFloat()
        Returns:
        This number converted to a float.
      • toInteger

        public int toInteger()
        Returns:
        This number converted to a int.
        Throws:
        java.lang.NumberFormatException - If this number contains decimals, uses exponent notation or is too large.
      • toInstant

        public java.time.Instant toInstant()
        Returns:
        This number converted to a Instant.
        Throws:
        java.time.DateTimeException - If this number is too large to be represented by an Instant.
        java.lang.ArithmeticException - If this number is too large.
      • toLong

        public long toLong()
        Returns:
        This number converted to a long.
        Throws:
        java.lang.NumberFormatException - If this number contains decimals, uses exponent notation or is too large.
      • toOffsetDateTime

        public java.time.OffsetDateTime toOffsetDateTime()
        Returns:
        This number converted to an OffsetDateTime.
        Throws:
        java.time.DateTimeException - If this number is too large to be represented by an OffsetDateTime.
        java.lang.ArithmeticException - If this number is too large.
      • toShort

        public short toShort()
        Returns:
        This number converted to a short.
        Throws:
        java.lang.NumberFormatException - If this number contains decimals, uses exponent notation or is too large.
      • readJson

        public static JsonNumber readJson​(BinaryReader source)
                                   throws DtoReadException
        Reads JSON number from given source.
        Parameters:
        source - Source containing JSON number at the current read offset, ignoring any whitespace.
        Returns:
        Decoded JSON number.
        Throws:
        DtoReadException - If the source does not contain a valid JSON number at the current read offset, or if the source could not be read.
      • readJson

        public static JsonNumber readJson​(se.arkalix.internal.dto.json.JsonTokenBuffer buffer)
                                   throws DtoReadException
        Internal API. Might change in breaking ways between patch versions of the Kalix library. Use is not advised.
        Throws:
        DtoReadException
      • equals

        public boolean equals​(java.lang.Object other)
        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