Author: jacopoc
Date: Fri Mar 26 14:27:49 2010
New Revision: 927867
URL:
http://svn.apache.org/viewvc?rev=927867&view=revLog:
I have forgotten to commit this in my previous commit (927783): now the ComparableRange class implements the Comparable interface.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/ComparableRange.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/ComparableRange.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/ComparableRange.java?rev=927867&r1=927866&r2=927867&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/ComparableRange.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/ComparableRange.java Fri Mar 26 14:27:49 2010
@@ -20,7 +20,7 @@ package org.ofbiz.base.lang;
/** An immutable range of values. */
@SourceMonitor("Adam Heath")
-public class ComparableRange<T extends Comparable<T>> implements Range<T> {
+public class ComparableRange<T extends Comparable<T>> implements Range<T>, Comparable<ComparableRange<T>> {
protected final T start;
protected final T end;
@@ -77,6 +77,13 @@ public class ComparableRange<T extends C
return false;
}
+ public int compareTo(ComparableRange<T> range) {
+ if (this == range) {
+ return 0;
+ }
+ return (this.start.equals(range.start)? this.end.compareTo(range.end()): this.start.compareTo(range.start()));
+ }
+
@Override
public boolean includes(Range<T> range) {
return this.includes(range.start()) && this.includes(range.end());