[dna-commits] DNA SVN: r721 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Jan 29 11:58:14 EST 2009


Author: rhauch
Date: 2009-01-29 11:58:14 -0500 (Thu, 29 Jan 2009)
New Revision: 721

Modified:
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java
Log:
DNA-279 Various improvements to the Graph API

Corrected BasicProperty to have a proper "compareTo(Property)" method.

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java	2009-01-29 02:33:07 UTC (rev 720)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/BasicProperty.java	2009-01-29 16:58:14 UTC (rev 721)
@@ -81,7 +81,20 @@
     /**
      * {@inheritDoc}
      */
-    public int compareTo( Property o ) {
+    public int compareTo( Property that ) {
+        if (this == that) return 0;
+        int diff = this.getName().compareTo(that.getName());
+        if (diff != 0) return diff;
+        diff = this.size() - that.size();
+        if (diff != 0) return diff;
+        Iterator<?> thisIter = iterator();
+        Iterator<?> thatIter = that.iterator();
+        while (thisIter.hasNext()) { // && thatIter.hasNext()
+            Object thisValue = thisIter.next();
+            Object thatValue = thatIter.next();
+            diff = ValueComparators.OBJECT_COMPARATOR.compare(thisValue, thatValue);
+            if (diff != 0) return diff;
+        }
         return 0;
     }
 




More information about the dna-commits mailing list