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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns thisRealNumber's value as aBigDecimalReturns the value of thisIntegeras aBigIntegerstatic <N extends ConcreteNumber & AtLeastZero,K extends ConcreteNumber & AtLeastZero & AtMost<? super N>>
Stream<K>count0ToN(N n) Returns a stream ofConcreteNumbers fromZEROtoNstatic <N extends ConcreteNumber & AtLeastOne,K extends ConcreteNumber & AtLeastZero & NMinus1<? extends AtMost<? super N>>>
Stream<K>count0ToNMinus1(N n) Returns a stream ofConcreteNumbers fromZEROtoN-1static <N extends ConcreteNumber & AtLeastZero,K extends ConcreteNumber & AtLeastOne & AtMost<? super N>>
Stream<K>count1ToN(N n) Returns a stream ofConcreteNumbers fromONEtoNstatic <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 ofConcreteNumbers fromMtoNbooleaninthashCode()static booleanhasType(int number) Determines if there is aConcreteNumbersubtype whose value equals the given intstatic booleanhasType(long number) Determines if there is aConcreteNumbersubtype whose value equals the given longintintValue()Returns the value of thisIntegeras a primitive int or throws an Exception if its not within int range.booleanisDouble()Determines if thisRealNumber's value has the precision of a primitive doublebooleanisInt()Returns true if this RationalNumber's numerator and denomiator are both in the range of primitive intsbooleanisLong()Returns true if this RationalNumber's numerator and denomiator are both in the range of primitive longslongReturns the value of thisIntegeras a primitive long or throws an Exception if its not within the range of long ints.static ConcreteNumberof(int n) Returns the ConcreteNumber whose value is the given intstatic <C extends ConcreteNumber & AtLeastZero>
CofNatural(int i) Returns aConcreteNumberwhose value is equal to the givenintwhich must be greater than or equal to 0.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.zfcj.math.numbers.Integer
compareTo, countTo, denominator, divide, doubleValue, greaterThan, greaterThanOrEqualTo, intDenominator, intNumerator, lessThan, lessThanOrEqualTo, longDenominator, longNumerator, minus, modulo, numerator, plus, timesMethods inherited from interface org.zfcj.math.numbers.RationalNumber
dividedBy, minus, plus, reduce, timesMethods inherited from interface org.zfcj.math.numbers.RealNumber
abs, almostEquals, almostEquals, dividedBy, greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo, minus, modulo, plus, pow, times, truncate
-
Constructor Details
-
ConcreteNumber
protected ConcreteNumber(int value)
-
-
Method Details
-
isInt
public boolean isInt()Description copied from interface:RationalNumberReturns true if this RationalNumber's numerator and denomiator are both in the range of primitive ints- Specified by:
isIntin interfaceRationalNumber- Returns:
- true if this
RationalNumberhas int precision, false otherwise
-
isLong
public boolean isLong()Description copied from interface:RationalNumberReturns true if this RationalNumber's numerator and denomiator are both in the range of primitive longs- Specified by:
isLongin interfaceRationalNumber- Returns:
- true if this
RationalNumberhas long precision, false otherwise
-
intValue
public int intValue()Description copied from interface:IntegerReturns the value of thisIntegeras a primitive int or throws an Exception if its not within int range. -
longValue
public long longValue()Description copied from interface:IntegerReturns the value of thisIntegeras a primitive long or throws an Exception if its not within the range of long ints. -
bigIntegerValue
Description copied from interface:IntegerReturns the value of thisIntegeras aBigInteger- Specified by:
bigIntegerValuein interfaceInteger- Returns:
- this
Integer'sBigIntegervalue
-
isDouble
public boolean isDouble()Description copied from interface:RealNumberDetermines if thisRealNumber's value has the precision of a primitive double- Specified by:
isDoublein interfaceRealNumber- Returns:
- true if this
RealNumberis double precision, false, if BigDecimal precision
-
bigDecimalValue
Description copied from interface:RealNumberReturns thisRealNumber's value as aBigDecimal- Specified by:
bigDecimalValuein interfaceRealNumber- Returns:
- the
BigDecimalvalue
-
hashCode
public int hashCode() -
equals
-
toString
-
count0ToN
public static <N extends ConcreteNumber & AtLeastZero,K extends ConcreteNumber & AtLeastZero & AtMost<? super N>> Stream<K> count0ToN(N n) Returns a stream ofConcreteNumbers fromZEROtoN- Type Parameters:
N- the type of theConcreteNumberto count toK- the type of theConcreteNumbers being counted- Parameters:
n- theConcreteNumberto count to- Returns:
- a
Streamof {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 ofConcreteNumbers fromZEROtoN-1 -
count1ToN
public static <N extends ConcreteNumber & AtLeastZero,K extends ConcreteNumber & AtLeastOne & AtMost<? super N>> Stream<K> count1ToN(N n) Returns a stream ofConcreteNumbers fromONEtoN- Type Parameters:
N- the type of theConcreteNumberto count toK- the type of theConcreteNumbers being counted- Parameters:
n- theConcreteNumberto count to- Returns:
- a
Streamof {code ConcreteNumber}s
-
countMToN
public static <M extends ConcreteNumber & AtMost<? super N>,N extends ConcreteNumber & AtLeast<? super M>, Stream<K> countMToNK extends ConcreteNumber & AtMost<? super N> & AtLeast<? super M>> (M m, N n) Returns a stream ofConcreteNumbers fromMtoN- Type Parameters:
M- the type of theConcreteNumberto count fromN- the type of theConcreteNumberto count toK- the type of theConcreteNumbers being counted- Parameters:
m- theConcreteNumberto count fromn- theConcreteNumberto count to- Returns:
- a
Streamof {code ConcreteNumber}s
-
hasType
public static boolean hasType(int number) Determines if there is aConcreteNumbersubtype whose value equals the given int- Parameters:
number- the value of theConcreteNumber- Returns:
- true if such a
ConcreteNumberexists, false otherwise
-
hasType
public static boolean hasType(long number) Determines if there is aConcreteNumbersubtype whose value equals the given long- Parameters:
number- the value of theConcreteNumber- Returns:
- true if such a
ConcreteNumberexists, false otherwise
-
of
Returns the ConcreteNumber whose value is the given int- Parameters:
n-- Returns:
-
ofNatural
Returns aConcreteNumberwhose value is equal to the givenintwhich must be greater than or equal to 0.- Type Parameters:
C- the type of theConcreteNumberandNaturalNumber- Parameters:
i- the (integer) natural number- Returns:
- a
ConcreteNumberequivalent to the given int
-