Author: jfuerth
Date: Tue Sep 30 09:05:37 2008
New Revision: 2734
Added:
trunk/lib/annotations.jar (contents, props changed)
Modified:
trunk/.classpath
trunk/src/ca/sqlpower/architect/diff/SQLIndexComparator.java
trunk/src/ca/sqlpower/architect/diff/SQLObjectComparator.java
Log:
Explained away the findbugs warning about comparing strings with ==. This
requires the FindBugs annotations.jar to be added to the runtime classpath,
which I have done.
I also added a missing doc comment and marked the comparators as
serializable because they're easy to serialize and fundbugs suggested it's
a good idea.
Modified: trunk/.classpath
==============================================================================
--- trunk/.classpath (original)
+++ trunk/.classpath Tue Sep 30 09:05:37 2008
@@ -38,5 +38,6 @@
<classpathentry kind="lib" path="jdbc_drivers/sqlserver_2005.jar"/>
<classpathentry kind="lib" path="lib/mondrian.jar"/>
<classpathentry kind="lib" path="lib/eigenbase-properties.jar"/>
+ <classpathentry kind="lib" path="lib/annotations.jar"/>
<classpathentry kind="output" path="build"/>
</classpath>
Added: trunk/lib/annotations.jar
==============================================================================
Binary file. No diff available.
Modified: trunk/src/ca/sqlpower/architect/diff/SQLIndexComparator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/diff/SQLIndexComparator.java
(original)
+++ trunk/src/ca/sqlpower/architect/diff/SQLIndexComparator.java Tue Sep 30
09:05:37 2008
@@ -18,6 +18,7 @@
*/
package ca.sqlpower.architect.diff;
+import java.io.Serializable;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Set;
@@ -37,7 +38,7 @@
* to be the same as [EMAIL PROTECTED] AscendDescend#UNSPECIFIED}.
*
*/
-public class SQLIndexComparator implements Comparator<SQLIndex> {
+public class SQLIndexComparator implements Comparator<SQLIndex>,
Serializable {
private static Logger logger =
Logger.getLogger(SQLIndexComparator.class);
@@ -150,12 +151,19 @@
return 0;
}
- /**
- * Performs the String.compareTo() but with null checks as well.
- *
- * @param source The "left side" for the comparison.
- * @param target The "right side" for the comparison.
- */
+ /**
+ * Performs the String.compareTo() but with null checks as well. Null
+ * is treated as less than non-null and equal to null.
+ *
+ * @param source
+ * The "left side" for the comparison.
+ * @param target
+ * The "right side" for the comparison.
+ */
+ @edu.umd.cs.findbugs.annotations.SuppressWarnings(
+ value={"ES_COMPARING_PARAMETER_STRING_WITH_EQ"},
+ justification="It's just a pre-check for null==null or reference
equality by luck. " +
+ "Falls back to String.equals() at the end of
the method.")
public int compareString(String source, String target) {
if (source == target) {
return 0;
Modified: trunk/src/ca/sqlpower/architect/diff/SQLObjectComparator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/diff/SQLObjectComparator.java
(original)
+++ trunk/src/ca/sqlpower/architect/diff/SQLObjectComparator.java Tue Sep
30 09:05:37 2008
@@ -18,11 +18,12 @@
*/
package ca.sqlpower.architect.diff;
+import java.io.Serializable;
import java.util.Comparator;
import ca.sqlpower.architect.SQLObject;
-public class SQLObjectComparator implements Comparator<SQLObject> {
+public class SQLObjectComparator implements Comparator<SQLObject>,
Serializable {
public int compare(SQLObject t1, SQLObject t2) {
// if t1 and t2 refer to the same object, or are both null, then they're
equal