Author: desruisseaux
Date: Wed Oct 2 15:32:05 2013
New Revision: 1528522
URL: http://svn.apache.org/r1528522
Log:
Slight simplification of Matrix3 and Matrix4 by the removal of their large
'equals' method,
replaced by a default implementation provided in SIS.
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix4.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java?rev=1528522&r1=1528521&r2=1528522&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
[UTF-8] Wed Oct 2 15:32:05 2013
@@ -455,32 +455,6 @@ class GeneralMatrix extends MatrixSIS {
}
/**
- * Returns {@code true} if the specified object is of type {@code
GeneralMatrix} and
- * all of the data members are equal to the corresponding data members in
this matrix.
- *
- * @param object The object to compare with this matrix for equality.
- * @return {@code true} if the given object is equal to this matrix.
- */
- @Override
- public final boolean equals(final Object object) {
- if (object instanceof GeneralMatrix) {
- final GeneralMatrix that = (GeneralMatrix) object;
- return numRow == that.numRow &&
- numCol == that.numCol &&
- Arrays.equals(elements, that.elements);
- }
- return false;
- }
-
- /**
- * Returns a hash code value based on the data values in this object.
- */
- @Override
- public final int hashCode() {
- return ((numRow << Short.SIZE) | numCol) ^ Arrays.hashCode(elements) ^
(int) serialVersionUID;
- }
-
- /**
* {@inheritDoc}
*/
@Override
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java?rev=1528522&r1=1528521&r2=1528522&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix3.java
[UTF-8] Wed Oct 2 15:32:05 2013
@@ -16,9 +16,7 @@
*/
package org.apache.sis.referencing.operation.matrix;
-import java.util.Arrays;
import org.opengis.referencing.operation.Matrix;
-import org.apache.sis.internal.util.Numerics;
import org.apache.sis.math.MathFunctions;
@@ -321,36 +319,4 @@ public final class Matrix3 extends Matri
public MatrixSIS solve(final Matrix matrix) throws
MismatchedMatrixSizeException, NoninvertibleMatrixException {
throw new UnsupportedOperationException(); // TODO
}
-
- /**
- * Returns {@code true} if the specified object is of type {@code Matrix3}
and
- * all of the data members are equal to the corresponding data members in
this matrix.
- *
- * @param object The object to compare with this matrix for equality.
- * @return {@code true} if the given object is equal to this matrix.
- */
- @Override
- public boolean equals(final Object object) {
- if (object instanceof Matrix3) {
- final Matrix3 that = (Matrix3) object;
- return Numerics.equals(this.m00, that.m00) &&
- Numerics.equals(this.m01, that.m01) &&
- Numerics.equals(this.m02, that.m02) &&
- Numerics.equals(this.m10, that.m10) &&
- Numerics.equals(this.m11, that.m11) &&
- Numerics.equals(this.m12, that.m12) &&
- Numerics.equals(this.m20, that.m20) &&
- Numerics.equals(this.m21, that.m21) &&
- Numerics.equals(this.m22, that.m22);
- }
- return false;
- }
-
- /**
- * Returns a hash code value based on the data values in this object.
- */
- @Override
- public int hashCode() {
- return Arrays.hashCode(getElements()) ^ (int) serialVersionUID;
- }
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix4.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix4.java?rev=1528522&r1=1528521&r2=1528522&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix4.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrix4.java
[UTF-8] Wed Oct 2 15:32:05 2013
@@ -16,9 +16,7 @@
*/
package org.apache.sis.referencing.operation.matrix;
-import java.util.Arrays;
import org.opengis.referencing.operation.Matrix;
-import org.apache.sis.internal.util.Numerics;
import org.apache.sis.math.MathFunctions;
@@ -372,43 +370,4 @@ public final class Matrix4 extends Matri
public MatrixSIS solve(final Matrix matrix) throws
MismatchedMatrixSizeException, NoninvertibleMatrixException {
throw new UnsupportedOperationException(); // TODO
}
-
- /**
- * Returns {@code true} if the specified object is of type {@code Matrix4}
and
- * all of the data members are equal to the corresponding data members in
this matrix.
- *
- * @param object The object to compare with this matrix for equality.
- * @return {@code true} if the given object is equal to this matrix.
- */
- @Override
- public boolean equals(final Object object) {
- if (object instanceof Matrix4) {
- final Matrix4 that = (Matrix4) object;
- return Numerics.equals(this.m00, that.m00) &&
- Numerics.equals(this.m01, that.m01) &&
- Numerics.equals(this.m02, that.m02) &&
- Numerics.equals(this.m03, that.m03) &&
- Numerics.equals(this.m10, that.m10) &&
- Numerics.equals(this.m11, that.m11) &&
- Numerics.equals(this.m12, that.m12) &&
- Numerics.equals(this.m13, that.m13) &&
- Numerics.equals(this.m20, that.m20) &&
- Numerics.equals(this.m21, that.m21) &&
- Numerics.equals(this.m22, that.m22) &&
- Numerics.equals(this.m23, that.m23) &&
- Numerics.equals(this.m30, that.m30) &&
- Numerics.equals(this.m31, that.m31) &&
- Numerics.equals(this.m32, that.m32) &&
- Numerics.equals(this.m33, that.m33);
- }
- return false;
- }
-
- /**
- * Returns a hash code value based on the data values in this object.
- */
- @Override
- public int hashCode() {
- return Arrays.hashCode(getElements()) ^ (int) serialVersionUID;
- }
}
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java?rev=1528522&r1=1528521&r2=1528522&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
(original)
+++
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
Wed Oct 2 15:32:05 2013
@@ -16,6 +16,7 @@
*/
package org.apache.sis.referencing.operation.matrix;
+import java.util.Arrays;
import java.io.Serializable;
import org.opengis.referencing.operation.Matrix;
import org.apache.sis.util.ArgumentChecks;
@@ -303,6 +304,33 @@ public abstract class MatrixSIS implemen
}
/**
+ * Returns {@code true} if the specified object is of same type than
{@code this} and
+ * all of the data members are equal to the corresponding data members in
this matrix.
+ *
+ * @param object The object to compare with this matrix for equality.
+ * @return {@code true} if the given object is equal to this matrix.
+ */
+ @Override
+ public boolean equals(final Object object) {
+ if (object != null && object.getClass() == getClass()) {
+ final MatrixSIS that = (MatrixSIS) object;
+ return getNumRow() == that.getNumRow() &&
+ getNumCol() == that.getNumCol() &&
+ Arrays.equals(getExtendedElements(),
that.getExtendedElements());
+ }
+ return false;
+ }
+
+ /**
+ * Returns a hash code value based on the data values in this object.
+ */
+ @Override
+ public int hashCode() {
+ return (getNumRow() << Short.SIZE) ^ getNumCol() ^
+ Arrays.hashCode(getExtendedElements()) ^ (int)
serialVersionUID;
+ }
+
+ /**
* Returns a clone of this matrix.
*
* @return A new matrix of the same class and with the same values than
this matrix.