diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/PointValuePair.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/PointValuePair.java index 2d1a62c58..ae2a4da2c 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/PointValuePair.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/PointValuePair.java @@ -17,7 +17,6 @@ package org.apache.commons.math4.legacy.optim; import java.util.Arrays; -import java.io.Serializable; import org.apache.commons.math4.legacy.core.Pair; @@ -29,11 +28,7 @@ import org.apache.commons.math4.legacy.core.Pair; * @see org.apache.commons.math4.legacy.analysis.MultivariateFunction * @since 3.0 */ -public final class PointValuePair extends Pair - implements Serializable { - /** Serializable UID. */ - private static final long serialVersionUID = 20120513L; - +public final class PointValuePair extends Pair { /** * Builds a point/objective function value pair. * @@ -105,44 +100,4 @@ public final class PointValuePair extends Pair public String toString() { return "[" + Arrays.toString(getPointRef()) + ", " + getValue() + "]"; } - - /** - * Replace the instance with a data transfer object for serialization. - * @return data transfer object that will be serialized - */ - private Object writeReplace() { - return new DataTransferObject(getKey(), getValue()); - } - - /** Internal class used only for serialization. */ - private static class DataTransferObject implements Serializable { - /** Serializable UID. */ - private static final long serialVersionUID = 20120513L; - /** - * Point coordinates. - * @Serial - */ - private final double[] point; - /** - * Value of the objective function at the point. - * @Serial - */ - private final double value; - - /** Simple constructor. - * @param point Point coordinates. - * @param value Value of the objective function at the point. - */ - DataTransferObject(final double[] point, final double value) { - this.point = point.clone(); - this.value = value; - } - - /** Replace the deserialized data transfer object with a {@link PointValuePair}. - * @return replacement {@link PointValuePair} - */ - private Object readResolve() { - return new PointValuePair(point, value, false); - } - } } diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointValuePairTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointValuePairTest.java index 3bb762269..18f1833f5 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointValuePairTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointValuePairTest.java @@ -21,17 +21,6 @@ import org.junit.Assert; import org.junit.Test; public class PointValuePairTest { - @Test - public void testSerial() { - PointValuePair pv1 = new PointValuePair(new double[] { 1.0, 2.0, 3.0 }, 4.0); - PointValuePair pv2 = (PointValuePair) TestUtils.serializeAndRecover(pv1); - Assert.assertEquals(pv1.getKey().length, pv2.getKey().length); - for (int i = 0; i < pv1.getKey().length; ++i) { - Assert.assertEquals(pv1.getKey()[i], pv2.getKey()[i], 1.0e-15); - } - Assert.assertEquals(pv1.getValue(), pv2.getValue(), 1.0e-15); - } - @Test public void testEquals() { final double[] p1 = new double[] { 1 };