another round of exception incompatibilities squashing
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_X@1073658 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1e060d02b7
commit
8d01241820
|
@ -25,7 +25,7 @@ import org.apache.commons.math.exception.util.LocalizedFormats;
|
|||
* @since 2.2
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
public class NoDataException extends MathIllegalArgumentException {
|
||||
public class NoDataException extends MathIllegalStateException {
|
||||
|
||||
/** Serializable version Id. */
|
||||
private static final long serialVersionUID = -3629324471511904459L;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.math.BigInteger;
|
|||
import org.apache.commons.math.FieldElement;
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
|
@ -115,10 +114,10 @@ public class BigFraction
|
|||
*/
|
||||
public BigFraction(BigInteger num, BigInteger den) {
|
||||
if (num == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.NUMERATOR);
|
||||
throw new NullPointerException(LocalizedFormats.NUMERATOR.getSourceString());
|
||||
}
|
||||
if (den == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.DENOMINATOR);
|
||||
throw new NullPointerException(LocalizedFormats.DENOMINATOR.getSourceString());
|
||||
}
|
||||
if (BigInteger.ZERO.equals(den)) {
|
||||
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
|
||||
|
@ -501,11 +500,11 @@ public class BigFraction
|
|||
* @param fraction
|
||||
* the {@link BigFraction} to add, must not be <code>null</code>.
|
||||
* @return a {@link BigFraction} instance with the resulting values.
|
||||
* @throws NullArgumentException if the {@link BigFraction} is {@code null}.
|
||||
* @throws NullPointerException if the {@link BigFraction} is {@code null}.
|
||||
*/
|
||||
public BigFraction add(final BigFraction fraction) {
|
||||
if (fraction == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FRACTION);
|
||||
throw new NullPointerException(LocalizedFormats.FRACTION.getSourceString());
|
||||
}
|
||||
if (ZERO.equals(fraction)) {
|
||||
return this;
|
||||
|
@ -657,12 +656,12 @@ public class BigFraction
|
|||
*
|
||||
* @param fraction Fraction to divide by, must not be {@code null}.
|
||||
* @return a {@link BigFraction} instance with the resulting values.
|
||||
* @throws NullArgumentException if the {@code fraction} is {@code null}.
|
||||
* @throws NullPointerException if the {@code fraction} is {@code null}.
|
||||
* @throws ArithmeticException if the fraction to divide by is zero.
|
||||
*/
|
||||
public BigFraction divide(final BigFraction fraction) {
|
||||
if (fraction == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FRACTION);
|
||||
throw new NullPointerException(LocalizedFormats.FRACTION.getSourceString());
|
||||
}
|
||||
if (BigInteger.ZERO.equals(fraction.numerator)) {
|
||||
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
|
||||
|
@ -844,11 +843,11 @@ public class BigFraction
|
|||
*
|
||||
* @param bg the {@code BigInteger} to multiply by.
|
||||
* @return a {@code BigFraction} instance with the resulting values.
|
||||
* @throws NullArgumentException if {@code bg} is {@code null}.
|
||||
* @throws NullPointerException if {@code bg} is {@code null}.
|
||||
*/
|
||||
public BigFraction multiply(final BigInteger bg) {
|
||||
if (bg == null) {
|
||||
throw new NullArgumentException();
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new BigFraction(bg.multiply(numerator), denominator);
|
||||
}
|
||||
|
@ -889,11 +888,11 @@ public class BigFraction
|
|||
*
|
||||
* @param fraction Fraction to multiply by, must not be {@code null}.
|
||||
* @return a {@link BigFraction} instance with the resulting values.
|
||||
* @throws NullArgumentException if {@code fraction} is {@code null}.
|
||||
* @throws NullPointerException if {@code fraction} is {@code null}.
|
||||
*/
|
||||
public BigFraction multiply(final BigFraction fraction) {
|
||||
if (fraction == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FRACTION);
|
||||
throw new NullPointerException(LocalizedFormats.FRACTION.getSourceString());
|
||||
}
|
||||
if (numerator.equals(BigInteger.ZERO) ||
|
||||
fraction.numerator.equals(BigInteger.ZERO)) {
|
||||
|
@ -1031,11 +1030,11 @@ public class BigFraction
|
|||
*
|
||||
* @param bg the {@link BigInteger} to subtract, cannot be {@code null}.
|
||||
* @return a {@code BigFraction} instance with the resulting values.
|
||||
* @throws NullArgumentException if the {@link BigInteger} is {@code null}.
|
||||
* @throws NullPointerException if the {@link BigInteger} is {@code null}.
|
||||
*/
|
||||
public BigFraction subtract(final BigInteger bg) {
|
||||
if (bg == null) {
|
||||
throw new NullArgumentException();
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new BigFraction(numerator.subtract(denominator.multiply(bg)), denominator);
|
||||
}
|
||||
|
@ -1077,11 +1076,11 @@ public class BigFraction
|
|||
*
|
||||
* @param fraction {@link BigFraction} to subtract, must not be {@code null}.
|
||||
* @return a {@link BigFraction} instance with the resulting values
|
||||
* @throws NullArgumentException if the {@code fraction} is {@code null}.
|
||||
* @throws NullPointerException if the {@code fraction} is {@code null}.
|
||||
*/
|
||||
public BigFraction subtract(final BigFraction fraction) {
|
||||
if (fraction == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.FRACTION);
|
||||
throw new NullPointerException(LocalizedFormats.FRACTION.getSourceString());
|
||||
}
|
||||
if (ZERO.equals(fraction)) {
|
||||
return this;
|
||||
|
|
|
@ -88,6 +88,7 @@ public interface UnivariateRealOptimizer extends ConvergingAlgorithm {
|
|||
* @throws FunctionEvaluationException if an error occurs evaluating the function.
|
||||
* @throws IllegalArgumentException if min > max or the arguments do not
|
||||
* satisfy the requirements specified by the optimizer.
|
||||
* @throws IllegalStateException if there are no data.
|
||||
*/
|
||||
double optimize(UnivariateRealFunction f, GoalType goalType,
|
||||
double min, double max, double startValue)
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.Serializable;
|
|||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
|
||||
/**
|
||||
* A Default NumberTransformer for java.lang.Numbers and Numeric Strings. This
|
||||
|
@ -40,12 +39,11 @@ public class DefaultTransformer implements NumberTransformer, Serializable {
|
|||
* @param o the object that gets transformed.
|
||||
* @return a double primitive representation of the Object o.
|
||||
* @throws MathException if it cannot successfully be transformed.
|
||||
* @throws NullArgumentException if is {@code null}.
|
||||
* @see <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/Transformer.html">Commons Collections Transformer</a>
|
||||
*/
|
||||
public double transform(Object o) throws MathException {
|
||||
if (o == null) {
|
||||
throw new NullArgumentException(LocalizedFormats.OBJECT_TRANSFORMATION);
|
||||
throw new MathException(LocalizedFormats.OBJECT_TRANSFORMATION);
|
||||
}
|
||||
|
||||
if (o instanceof Number) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.math.BigInteger;
|
|||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.TestUtils;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -66,14 +65,14 @@ public class BigFractionTest extends TestCase {
|
|||
assertFraction(1055531162664967l, 70368744177664l, new BigFraction(15.0000000000001));
|
||||
try {
|
||||
new BigFraction(null, BigInteger.ONE);
|
||||
fail("Expecting NullArgumentException");
|
||||
} catch (NullArgumentException npe) {
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException npe) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
new BigFraction(BigInteger.ONE, null);
|
||||
fail("Expecting NullArgumentException");
|
||||
} catch (NullArgumentException npe) {
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException npe) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
|
@ -330,8 +329,8 @@ public class BigFractionTest extends TestCase {
|
|||
|
||||
try {
|
||||
f.add((BigFraction) null);
|
||||
fail("expecting NullArgumentException");
|
||||
} catch (NullArgumentException ex) {
|
||||
fail("expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
|
||||
// if this fraction is added naively, it will overflow.
|
||||
|
@ -418,8 +417,8 @@ public class BigFractionTest extends TestCase {
|
|||
|
||||
try {
|
||||
f.divide((BigFraction) null);
|
||||
fail("expecting NullArgumentException");
|
||||
} catch (NullArgumentException ex) {
|
||||
fail("expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
|
||||
f1 = new BigFraction(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
|
@ -464,8 +463,8 @@ public class BigFractionTest extends TestCase {
|
|||
|
||||
try {
|
||||
f.multiply((BigFraction) null);
|
||||
fail("expecting NullArgumentException");
|
||||
} catch (NullArgumentException ex) {
|
||||
fail("expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -482,8 +481,8 @@ public class BigFractionTest extends TestCase {
|
|||
BigFraction f = new BigFraction(1, 1);
|
||||
try {
|
||||
f.subtract((BigFraction) null);
|
||||
fail("expecting NullArgumentException");
|
||||
} catch (NullArgumentException ex) {
|
||||
fail("expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
|
||||
// if this fraction is subtracted naively, it will overflow.
|
||||
|
|
|
@ -23,7 +23,6 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.TestUtils;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
|
||||
/**
|
||||
* @version $Revision$ $Date$
|
||||
|
@ -46,8 +45,8 @@ public class DefaultTransformerTest extends TestCase {
|
|||
DefaultTransformer t = new DefaultTransformer();
|
||||
try {
|
||||
t.transform(null);
|
||||
fail("Expecting NullArgumentException");
|
||||
} catch (NullArgumentException e) {
|
||||
fail("Expecting MathException");
|
||||
} catch (MathException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue