Class ConcreteNumber

java.lang.Object
org.zfcj.math.numbers.concrete.ConcreteNumber
All Implemented Interfaces:
Comparable<RealNumber>, Integer, Number, RationalNumber, RealNumber
Direct Known Subclasses:
Eight, Eighteen, Eleven, Fifteen, Five, Four, Fourteen, MinusOne, Nine, Nineteen, One, Seven, Seventeen, Six, Sixteen, Ten, Thirteen, Three, Twelve, Twenty, Two, Zero

public abstract sealed class ConcreteNumber extends Object implements Integer permits MinusOne, Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen, Sixteen, Seventeen, Eighteen, Nineteen, Twenty
A ConcreteNumber is an Integer whose value is always the same specific integer and is identified by its type name. It is the abstract base class for the singleton types MinusOne, Zero, One, etc. and is auto-generated along with those types.
  • Constructor Details

    • ConcreteNumber

      protected ConcreteNumber(int value)
  • Method Details

    • isInt

      public boolean isInt()
      Description copied from interface: RationalNumber
      Returns true if this RationalNumber's numerator and denomiator are both in the range of primitive ints
      Specified by:
      isInt in interface RationalNumber
      Returns:
      true if this RationalNumber has int precision, false otherwise
    • isLong

      public boolean isLong()
      Description copied from interface: RationalNumber
      Returns true if this RationalNumber's numerator and denomiator are both in the range of primitive longs
      Specified by:
      isLong in interface RationalNumber
      Returns:
      true if this RationalNumber has long precision, false otherwise
    • intValue

      public int intValue()
      Description copied from interface: Integer
      Returns the value of this Integer as a primitive int or throws an Exception if its not within int range.
      Specified by:
      intValue in interface Integer
      Returns:
      an int that represents this integer
    • longValue

      public long longValue()
      Description copied from interface: Integer
      Returns the value of this Integer as a primitive long or throws an Exception if its not within the range of long ints.
      Specified by:
      longValue in interface Integer
      Returns:
      a long that represents this integer
    • bigIntegerValue

      public BigInteger bigIntegerValue()
      Description copied from interface: Integer
      Returns the value of this Integer as a BigInteger
      Specified by:
      bigIntegerValue in interface Integer
      Returns:
      this Integer's BigInteger value
    • isDouble

      public boolean isDouble()
      Description copied from interface: RealNumber
      Determines if this RealNumber's value has the precision of a primitive double
      Specified by:
      isDouble in interface RealNumber
      Returns:
      true if this RealNumber is double precision, false, if BigDecimal precision
    • bigDecimalValue

      public BigDecimal bigDecimalValue()
      Description copied from interface: RealNumber
      Returns this RealNumber's value as a BigDecimal
      Specified by:
      bigDecimalValue in interface RealNumber
      Returns:
      the BigDecimal value
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • count0ToN

      public static <N extends ConcreteNumber & AtLeastZero, K extends ConcreteNumber & AtLeastZero & AtMost<? super N>> Stream<K> count0ToN(N n)
      Returns a stream of ConcreteNumbers from ZERO to N
      Type Parameters:
      N - the type of the ConcreteNumber to count to
      K - the type of the ConcreteNumbers being counted
      Parameters:
      n - the ConcreteNumber to count to
      Returns:
      a Stream of {code ConcreteNumber}s
    • count0ToNMinus1

      public static <N extends ConcreteNumber & AtLeastOne, K extends ConcreteNumber & AtLeastZero & NMinus1<? extends AtMost<? super N>>> Stream<K> count0ToNMinus1(N n)
      Returns a stream of ConcreteNumbers from ZERO to N-1
    • count1ToN

      public static <N extends ConcreteNumber & AtLeastZero, K extends ConcreteNumber & AtLeastOne & AtMost<? super N>> Stream<K> count1ToN(N n)
      Returns a stream of ConcreteNumbers from ONE to N
      Type Parameters:
      N - the type of the ConcreteNumber to count to
      K - the type of the ConcreteNumbers being counted
      Parameters:
      n - the ConcreteNumber to count to
      Returns:
      a Stream of {code ConcreteNumber}s
    • countMToN

      public static <M extends ConcreteNumber & AtMost<? super N>, N extends ConcreteNumber & AtLeast<? super M>, K extends ConcreteNumber & AtMost<? super N> & AtLeast<? super M>> Stream<K> countMToN(M m, N n)
      Returns a stream of ConcreteNumbers from M to N
      Type Parameters:
      M - the type of the ConcreteNumber to count from
      N - the type of the ConcreteNumber to count to
      K - the type of the ConcreteNumbers being counted
      Parameters:
      m - the ConcreteNumber to count from
      n - the ConcreteNumber to count to
      Returns:
      a Stream of {code ConcreteNumber}s
    • hasType

      public static boolean hasType(int number)
      Determines if there is a ConcreteNumber subtype whose value equals the given int
      Parameters:
      number - the value of the ConcreteNumber
      Returns:
      true if such a ConcreteNumber exists, false otherwise
    • hasType

      public static boolean hasType(long number)
      Determines if there is a ConcreteNumber subtype whose value equals the given long
      Parameters:
      number - the value of the ConcreteNumber
      Returns:
      true if such a ConcreteNumber exists, false otherwise
    • of

      public static ConcreteNumber of(int n)
      Returns the ConcreteNumber whose value is the given int
      Parameters:
      n -
      Returns:
    • ofNatural

      public static <C extends ConcreteNumber & AtLeastZero> C ofNatural(int i)
      Returns a ConcreteNumber whose value is equal to the given int which must be greater than or equal to 0.
      Type Parameters:
      C - the type of the ConcreteNumber and NaturalNumber
      Parameters:
      i - the (integer) natural number
      Returns:
      a ConcreteNumber equivalent to the given int