You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2022/01/01 10:19:58 UTC
[commons-math] 04/11: MATH-1594: Remove "Serializable".
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit 89f0abb4ea03816b8d27160fcdf35381871bf351
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Thu Dec 30 23:29:18 2021 +0100
MATH-1594: Remove "Serializable".
---
.../commons/math4/legacy/optim/PointValuePair.java | 47 +---------------------
.../math4/legacy/optim/PointValuePairTest.java | 11 -----
2 files changed, 1 insertion(+), 57 deletions(-)
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 2d1a62c..ae2a4da 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<double[], Double>
- implements Serializable {
- /** Serializable UID. */
- private static final long serialVersionUID = 20120513L;
-
+public final class PointValuePair extends Pair<double[], Double> {
/**
* Builds a point/objective function value pair.
*
@@ -105,44 +100,4 @@ public final class PointValuePair extends Pair<double[], Double>
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 3bb7622..18f1833 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
@@ -22,17 +22,6 @@ 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 };
final PointValuePair pv1 = new PointValuePair(p1, 2);