Class NonMonotonicSequenceException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.apache.commons.math4.legacy.exception.MathRuntimeException
-
- org.apache.commons.math4.legacy.exception.MathIllegalArgumentException
-
- org.apache.commons.math4.legacy.exception.MathIllegalNumberException
-
- org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException
-
- All Implemented Interfaces:
Serializable
,ExceptionContextProvider
public class NonMonotonicSequenceException extends MathIllegalNumberException
Exception to be thrown when the a sequence of values is not monotonically increasing or decreasing.- Since:
- 2.2 (name changed to "NonMonotonicSequenceException" in 3.0)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.commons.math4.legacy.exception.MathIllegalNumberException
INTEGER_ZERO
-
-
Constructor Summary
Constructors Constructor Description NonMonotonicSequenceException(Number wrong, Number previous, int index)
Construct the exception.NonMonotonicSequenceException(Number wrong, Number previous, int index, boolean increasing, boolean strict)
Construct the exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getIncreasing()
int
getIndex()
Get the index of the wrong value.Number
getPrevious()
boolean
getStrict()
-
Methods inherited from class org.apache.commons.math4.legacy.exception.MathIllegalNumberException
getArgument
-
Methods inherited from class org.apache.commons.math4.legacy.exception.MathRuntimeException
getContext, getLocalizedMessage, getMessage
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
NonMonotonicSequenceException
public NonMonotonicSequenceException(Number wrong, Number previous, int index)
Construct the exception. This constructor uses default values assuming that the sequence should have been strictly increasing.- Parameters:
wrong
- Value that did not match the requirements.previous
- Previous value in the sequence.index
- Index of the value that did not match the requirements.
-
NonMonotonicSequenceException
public NonMonotonicSequenceException(Number wrong, Number previous, int index, boolean increasing, boolean strict)
Construct the exception.- Parameters:
wrong
- Value that did not match the requirements.previous
- Previous value in the sequence.index
- Index of the value that did not match the requirements.increasing
-true
for a sequence required to be increasing,false
for a decreasing sequence.strict
- Whether the sequence must be strictly increasing or decreasing.
-
-
Method Detail
-
getIncreasing
public boolean getIncreasing()
- Returns:
true
if the sequence should be increasing.
-
getStrict
public boolean getStrict()
- Returns:
true
is the sequence should be strictly monotonic.
-
getIndex
public int getIndex()
Get the index of the wrong value.- Returns:
- the current index.
-
getPrevious
public Number getPrevious()
- Returns:
- the previous value.
-
-