Interface NumberValue

All Superinterfaces:
Comparable<NumberValue>, Node<Number>, ValueNode<Number>
All Known Implementing Classes:
ByteValue, DoubleValue, FloatValue, IntValue, LongValue, ShortValue

public sealed interface NumberValue extends ValueNode<Number>, Comparable<NumberValue> permits IntValue, LongValue, FloatValue, DoubleValue, ByteValue, ShortValue
An interface to represent that Node holds number.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final NumberValue
    A NumberValue that represents zero.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    Gets the number as byte.
    double
    Gets the number as double.
    float
    Gets the number as float.
    int
    Gets the number as int.
    long
    Gets the number as long.
    short
    Gets the number as short.
    static @NotNull NumberValue
    fromNumber(@Nullable Number value)
    Creates NumberValue from the given Number.
    default boolean
    Checks if this Node holds an object.

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface com.github.siroshun09.configapi.core.node.Node

    accept, asOptional

    Methods inherited from interface com.github.siroshun09.configapi.core.node.ValueNode

    value
  • Field Details

  • Method Details

    • fromNumber

      @NotNull static @NotNull NumberValue fromNumber(@Nullable @Nullable Number value)
      Creates NumberValue from the given Number.

      If the given number is zero, this method returns ZERO. For other values, the appropriate value record (IntValue, DoubleValue, etc.) is used.

      Supported Number types are as follows:

      Parameters:
      value - the number value
      Returns:
      a NumberValue with the given Number
    • hasValue

      default boolean hasValue()
      Description copied from interface: Node
      Checks if this Node holds an object.

      The default implementation of this method checks if the returning value from Node.value() is not null.

      Specified by:
      hasValue in interface Node<Number>
      Returns:
      true if this Node holds an object, otherwise false
    • asInt

      int asInt()
      Gets the number as int.
      Returns:
      the int value
    • asLong

      long asLong()
      Gets the number as long.
      Returns:
      the long value
    • asFloat

      float asFloat()
      Gets the number as float.
      Returns:
      the float value
    • asDouble

      double asDouble()
      Gets the number as double.
      Returns:
      the double value
    • asByte

      byte asByte()
      Gets the number as byte.
      Returns:
      the byte value
    • asShort

      short asShort()
      Gets the number as short.
      Returns:
      the short value