Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ public static Set<City> unique(City[] cities) {
/** {@inheritDoc} */
@Override
public boolean equals(Object o) {
if (o instanceof City) {
final City other = (City) o;
if (o instanceof City other) {
return x == other.x &&
y == other.y;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,7 @@ public boolean isZero() {
@Override
public boolean equals(final Object other) {

if (other instanceof Dfp) {
final Dfp x = (Dfp) other;
if (other instanceof Dfp x) {
if (isNaN() || x.isNaN() || field.getRadixDigits() != x.field.getRadixDigits()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ private static void reportFailedResults(Method mathMethod, Object[] params, Obje
String format = null;
long actL = 0;
long expL = 0;
if (expected instanceof Double) {
Double exp = (Double) expected;
if (expected instanceof Double exp) {
Double act = (Double) actual;
if (isNumber(exp) && isNumber(act) && exp != 0) { // show difference as hex
actL = Double.doubleToLongBits(act);
Expand All @@ -121,8 +120,7 @@ private static void reportFailedResults(Method mathMethod, Object[] params, Obje
}
format = "%016x";
}
} else if (expected instanceof Float) {
Float exp = (Float) expected;
} else if (expected instanceof Float exp) {
Float act = (Float) actual;
if (isNumber(exp) && isNumber(act) && exp != 0) { // show difference as hex
actL = Float.floatToIntBits(act);
Expand All @@ -143,13 +141,13 @@ private static void reportFailedResults(Method mathMethod, Object[] params, Obje
}
sb.append(") expected ");
if (format != null) {
sb.append(String.format(format, expL));
sb.append(format.formatted(expL));
} else {
sb.append(expected);
}
sb.append(" actual ");
if (format != null) {
sb.append(String.format(format, actL));
sb.append(format.formatted(actL));
} else {
sb.append(actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,11 @@ private static void assertAtan2(double y, double x, double numerator, double den
if (numerator == 0) {
// Exact including the sign.
Assertions.assertEquals(numerator, v,
() -> String.format("atan2(%s, %s) should be %s but was %s", y, x, numerator, v));
() -> "atan2(%s, %s) should be %s but was %s".formatted(y, x, numerator, v));
} else {
final double expected = AccurateMath.PI * numerator / denominator;
Assertions.assertEquals(expected, v, Precision.EPSILON,
() -> String.format("atan2(%s, %s) should be pi * %s / %s", y, x, numerator, denominator));
() -> "atan2(%s, %s) should be pi * %s / %s".formatted(y, x, numerator, denominator));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -27,6 +29,7 @@
*/
public class ConvergenceException extends MathIllegalStateException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = 4330003017885151975L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -26,6 +28,7 @@
*/
public class DimensionMismatchException extends MathIllegalNumberException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -8415396756375798143L;
/** Correct dimension. */
private final int dimension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -28,6 +30,7 @@ public class InsufficientDataException
extends MathIllegalArgumentException {

/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -2629324471511903359L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -29,6 +31,7 @@
*/
public class MathArithmeticException extends MathRuntimeException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -6024911025449780478L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;

/**
Expand All @@ -28,6 +30,7 @@
*/
public class MathIllegalArgumentException extends MathRuntimeException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -6024911025449780478L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;

/**
Expand All @@ -32,6 +34,7 @@ public class MathIllegalNumberException extends MathIllegalArgumentException {
protected static final Integer INTEGER_ZERO = Integer.valueOf(0);

/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -7447085893598031110L;

/** Requested. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -28,6 +30,7 @@
*/
public class MathIllegalStateException extends MathRuntimeException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -6024911025449780478L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -26,6 +28,7 @@
*/
public class MathInternalError extends MathIllegalStateException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -6276776513966934846L;
/** URL for reporting problems. */
private static final String REPORT_URL = "https://issues.apache.org/jira/browse/MATH";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

/**
Expand All @@ -25,6 +27,7 @@
*/
public class MathParseException extends MathIllegalStateException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -6024911025449780478L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.ExceptionContext;
import org.apache.commons.math4.legacy.exception.util.ExceptionContextProvider;
import org.apache.commons.math4.legacy.exception.util.Localizable;
Expand All @@ -32,6 +34,7 @@
public class MathRuntimeException extends RuntimeException
implements ExceptionContextProvider {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = 20120926L;
/** Context. */
private final ExceptionContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -29,6 +31,7 @@
*/
public class MathUnsupportedOperationException extends MathRuntimeException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -6024911025449780478L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -26,6 +28,7 @@
*/
public class MaxCountExceededException extends MathIllegalStateException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = 4330003017885151975L;
/**
* Maximum number of evaluations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -26,6 +28,7 @@
*/
public class MultiDimensionMismatchException extends MathIllegalArgumentException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -8415396756375798143L;

/** Wrong dimensions. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -27,6 +29,7 @@
*/
public class NoBracketingException extends MathIllegalArgumentException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -3629324471511904459L;
/** Lower end of the interval. */
private final double lo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -27,6 +29,7 @@
public class NoDataException extends MathIllegalArgumentException {

/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -3629324471511904459L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

/**
Expand All @@ -26,6 +28,7 @@
*/
public class NonMonotonicSequenceException extends MathIllegalNumberException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = 20210531L;
/**
* Whether the sequence should be increasing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

/**
Expand All @@ -25,6 +27,7 @@
*/
public class NotANumberException extends MathIllegalNumberException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = 20120906L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;

Expand All @@ -26,6 +28,7 @@
*/
public class NotFiniteNumberException extends MathIllegalNumberException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -6100997100383932834L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.commons.math4.legacy.exception;

import java.io.Serial;

import org.apache.commons.math4.legacy.exception.util.Localizable;

/**
Expand All @@ -25,6 +27,7 @@
*/
public class NotPositiveException extends NumberIsTooSmallException {
/** Serializable version Id. */
@Serial
private static final long serialVersionUID = -2250556892093726375L;

/**
Expand Down
Loading