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 eab5cb3af159ab9cbb27fdbd1ee484708dfc699c Author: Gilles Sadowski <gillese...@gmail.com> AuthorDate: Fri Dec 31 01:44:22 2021 +0100 MATH-1594: Remove "Serializable". --- .../legacy/optim/linear/LinearConstraint.java | 32 +-------------------- .../optim/linear/LinearObjectiveFunction.java | 33 +--------------------- .../math4/legacy/optim/linear/SimplexTableau.java | 33 +--------------------- .../legacy/optim/linear/SimplexTableauTest.java | 9 ------ 4 files changed, 3 insertions(+), 104 deletions(-) diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/LinearConstraint.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/LinearConstraint.java index 12fb204..5921d47 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/LinearConstraint.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/LinearConstraint.java @@ -16,11 +16,6 @@ */ package org.apache.commons.math4.legacy.optim.linear; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - import org.apache.commons.math4.legacy.linear.ArrayRealVector; import org.apache.commons.math4.legacy.linear.MatrixUtils; import org.apache.commons.math4.legacy.linear.RealVector; @@ -45,9 +40,7 @@ import org.apache.commons.math4.legacy.linear.RealVector; * * @since 2.0 */ -public class LinearConstraint implements Serializable { - /** Serializable version identifier. */ - private static final long serialVersionUID = -764632794033034092L; +public class LinearConstraint { /** Coefficients of the constraint (left hand side). */ private final transient RealVector coefficients; /** Relationship between left and right hand sides {@code (=, <=, >=)}. */ @@ -204,27 +197,4 @@ public class LinearConstraint implements Serializable { Double.valueOf(value).hashCode() ^ coefficients.hashCode(); } - - /** - * Serialize the instance. - * @param oos stream where object should be written - * @throws IOException if object cannot be written to stream - */ - private void writeObject(ObjectOutputStream oos) - throws IOException { - oos.defaultWriteObject(); - MatrixUtils.serializeRealVector(coefficients, oos); - } - - /** - * Deserialize the instance. - * @param ois stream from which the object should be read - * @throws ClassNotFoundException if a class in the stream cannot be found - * @throws IOException if object cannot be read from the stream - */ - private void readObject(ObjectInputStream ois) - throws ClassNotFoundException, IOException { - ois.defaultReadObject(); - MatrixUtils.deserializeRealVector(this, "coefficients", ois); - } } diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/LinearObjectiveFunction.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/LinearObjectiveFunction.java index bb99d42..5148e62 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/LinearObjectiveFunction.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/LinearObjectiveFunction.java @@ -16,11 +16,6 @@ */ package org.apache.commons.math4.legacy.optim.linear; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - import org.apache.commons.math4.legacy.analysis.MultivariateFunction; import org.apache.commons.math4.legacy.linear.ArrayRealVector; import org.apache.commons.math4.legacy.linear.MatrixUtils; @@ -41,10 +36,7 @@ import org.apache.commons.math4.legacy.optim.OptimizationData; */ public class LinearObjectiveFunction implements MultivariateFunction, - OptimizationData, - Serializable { - /** Serializable version identifier. */ - private static final long serialVersionUID = -4531815507568396090L; + OptimizationData { /** Coefficients of the linear equation (c<sub>i</sub>). */ private final transient RealVector coefficients; /** Constant term of the linear equation. */ @@ -125,27 +117,4 @@ public class LinearObjectiveFunction public int hashCode() { return Double.valueOf(constantTerm).hashCode() ^ coefficients.hashCode(); } - - /** - * Serialize the instance. - * @param oos stream where object should be written - * @throws IOException if object cannot be written to stream - */ - private void writeObject(ObjectOutputStream oos) - throws IOException { - oos.defaultWriteObject(); - MatrixUtils.serializeRealVector(coefficients, oos); - } - - /** - * Deserialize the instance. - * @param ois stream from which the object should be read - * @throws ClassNotFoundException if a class in the stream cannot be found - * @throws IOException if object cannot be read from the stream - */ - private void readObject(ObjectInputStream ois) - throws ClassNotFoundException, IOException { - ois.defaultReadObject(); - MatrixUtils.deserializeRealVector(this, "coefficients", ois); - } } diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/SimplexTableau.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/SimplexTableau.java index 02c3d06..6ffcbb1 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/SimplexTableau.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/SimplexTableau.java @@ -16,10 +16,6 @@ */ package org.apache.commons.math4.legacy.optim.linear; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -69,14 +65,10 @@ import org.apache.commons.numbers.core.Precision; * * @since 2.0 */ -class SimplexTableau implements Serializable { +class SimplexTableau { /** Column label for negative vars. */ private static final String NEGATIVE_VAR_COLUMN_LABEL = "x-"; - - /** Serializable version identifier. */ - private static final long serialVersionUID = -1369660067587938365L; - /** bit mask for IEEE double exponent. */ private static final long EXPN = 0x7ff0000000000000L; /** bit mask for IEEE double mantissa and sign. */ @@ -889,27 +881,4 @@ class SimplexTableau implements Serializable { constraints.hashCode() ^ tableau.hashCode(); } - - /** - * Serialize the instance. - * @param oos stream where object should be written - * @throws IOException if object cannot be written to stream - */ - private void writeObject(ObjectOutputStream oos) - throws IOException { - oos.defaultWriteObject(); - MatrixUtils.serializeRealMatrix(tableau, oos); - } - - /** - * Deserialize the instance. - * @param ois stream from which the object should be read - * @throws ClassNotFoundException if a class in the stream cannot be found - * @throws IOException if object cannot be read from the stream - */ - private void readObject(ObjectInputStream ois) - throws ClassNotFoundException, IOException { - ois.defaultReadObject(); - MatrixUtils.deserializeRealMatrix(this, "tableau", ois); - } } diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/linear/SimplexTableauTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/linear/SimplexTableauTest.java index a28a0f5..bec3f35 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/linear/SimplexTableauTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/linear/SimplexTableauTest.java @@ -76,15 +76,6 @@ public class SimplexTableauTest { assertMatrixEquals(initialTableau, tableau.getData()); } - @Test - public void testSerial() { - LinearObjectiveFunction f = createFunction(); - Collection<LinearConstraint> constraints = createConstraints(); - SimplexTableau tableau = - new SimplexTableau(f, constraints, GoalType.MAXIMIZE, false, 1.0e-6); - Assert.assertEquals(tableau, TestUtils.serializeAndRecover(tableau)); - } - private LinearObjectiveFunction createFunction() { return new LinearObjectiveFunction(new double[] {15, 10}, 0); }