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 9f633f7af452b00fc17078380b22a5262a4bb3e2 Author: Gilles Sadowski <gillese...@gmail.com> AuthorDate: Fri Dec 31 00:31:49 2021 +0100 MATH-1594: Remove "Serializable". --- .../math4/legacy/optim/PointVectorValuePair.java | 47 +--------------------- .../legacy/optim/PointVectorValuePairTest.java | 39 ------------------ 2 files changed, 1 insertion(+), 85 deletions(-) diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/PointVectorValuePair.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/PointVectorValuePair.java index f77532d..c169905 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/PointVectorValuePair.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/PointVectorValuePair.java @@ -16,8 +16,6 @@ */ package org.apache.commons.math4.legacy.optim; -import java.io.Serializable; - import org.apache.commons.math4.legacy.core.Pair; /** @@ -28,10 +26,7 @@ import org.apache.commons.math4.legacy.core.Pair; * @see org.apache.commons.math4.legacy.analysis.MultivariateVectorFunction * @since 3.0 */ -public class PointVectorValuePair extends Pair<double[], double[]> implements Serializable { - /** Serializable UID. */ - private static final long serialVersionUID = 20120513L; - +public class PointVectorValuePair extends Pair<double[], double[]> { /** * Builds a point/objective function value pair. * @@ -104,44 +99,4 @@ public class PointVectorValuePair extends Pair<double[], double[]> implements Se public double[] getValueRef() { return super.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.clone(); - } - - /** Replace the deserialized data transfer object with a {@link PointValuePair}. - * @return replacement {@link PointValuePair} - */ - private Object readResolve() { - return new PointVectorValuePair(point, value, false); - } - } } diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointVectorValuePairTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointVectorValuePairTest.java deleted file mode 100644 index f2dbf8a..0000000 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointVectorValuePairTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math4.legacy.optim; - -import org.apache.commons.math4.legacy.TestUtils; -import org.junit.Assert; -import org.junit.Test; - -public class PointVectorValuePairTest { - @Test - public void testSerial() { - PointVectorValuePair pv1 = new PointVectorValuePair(new double[] { 1.0, 2.0, 3.0 }, - new double[] { 4.0, 5.0 }); - PointVectorValuePair pv2 = (PointVectorValuePair) 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().length, pv2.getValue().length); - for (int i = 0; i < pv1.getValue().length; ++i) { - Assert.assertEquals(pv1.getValue()[i], pv2.getValue()[i], 1.0e-15); - } - } -}