Class NumberType<N extends Number>

java.lang.Object
io.github.projectunified.valuevenue.number.NumberType<N>
Type Parameters:
N - type of the number

public final class NumberType<N extends Number> extends Object
The numeric types a number source can produce, with the arithmetic of the type.

The integral types step in long, so they are exact and need no decimal arithmetic. The floating types step in BigDecimal, because a fractional step would drift in a binary float, and resolve to plain text without scientific notation.

The class is final and creates its constants itself, so it loads no other class of its own while it is being initialized.

  • Field Details

  • Method Details

    • values

      public Stream<N> values(Number start, Number end, Number step, boolean maxInclusive, Direction direction)
      The values of a range, from the start to the end.
      Parameters:
      start - the first value
      end - the last value, or its bound when it is not included
      step - the distance between two values, positive
      maxInclusive - whether the end is a value of the range
      direction - the direction the values step in
      Returns:
      stream of the values, empty when the direction cannot reach the end
    • format

      public String format(N value)
      The plain text of a number: no scientific notation, whatever its type.
      Parameters:
      value - the number
      Returns:
      the plain text