MATH-1594: Remove "Serializable".
This commit is contained in:
parent
4f0a49b674
commit
89f0abb4ea
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue