You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2013/11/09 01:29:43 UTC

svn commit: r1540231 - in /commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range: AbstractRange.java CharacterRange.java DoubleRange.java FloatRange.java IntegerRange.java LongRange.java NumericRange.java

Author: mbenson
Date: Sat Nov  9 00:29:42 2013
New Revision: 1540231

URL: http://svn.apache.org/r1540231
Log:
extract some duplicate Range code into AbstractRange

Added:
    commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/AbstractRange.java
Modified:
    commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/CharacterRange.java
    commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/DoubleRange.java
    commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/FloatRange.java
    commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/IntegerRange.java
    commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/LongRange.java
    commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/NumericRange.java

Added: commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/AbstractRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/AbstractRange.java?rev=1540231&view=auto
==============================================================================
--- commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/AbstractRange.java (added)
+++ commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/AbstractRange.java Sat Nov  9 00:29:42 2013
@@ -0,0 +1,132 @@
+package org.apache.commons.functor.range;
+
+import java.util.Collection;
+
+import org.apache.commons.lang3.Validate;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+
+/**
+ * Abstract {@link Range}
+ * 
+ * @param <T>
+ * @param <S>
+ */
+public abstract class AbstractRange<T extends Comparable<?>, S extends Comparable<?>> implements Range<T, S> {
+
+    /**
+     * Left limit.
+     */
+    protected final Endpoint<T> leftEndpoint;
+
+    /**
+     * Right limit.
+     */
+    protected final Endpoint<T> rightEndpoint;
+
+    /**
+     * Increment step.
+     */
+    protected final S step;
+
+    /**
+     * Create a new {@link AbstractRange}.
+     * 
+     * @param leftEndpoint
+     * @param rightEndpoint
+     * @param step
+     */
+    protected AbstractRange(Endpoint<T> leftEndpoint, Endpoint<T> rightEndpoint, S step) {
+        super();
+        this.leftEndpoint = Validate.notNull(leftEndpoint, "Left Endpoint argument must not be null");
+        this.rightEndpoint = Validate.notNull(rightEndpoint, "Right Endpoint argument must not be null");
+        this.step = Validate.notNull(step, "step must not be null");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Endpoint<T> getLeftEndpoint() {
+        return leftEndpoint;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Endpoint<T> getRightEndpoint() {
+        return rightEndpoint;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public S getStep() {
+        return step;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean containsAll(Collection<T> col) {
+        if (col == null || col.isEmpty()) {
+            return false;
+        }
+        for (T t : col) {
+            if (!contains(t)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    // iterable, iterator methods
+    // ---------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+    // object methods
+    // ---------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        final String pattern = "%s<%s, %s, %s>";
+        return String.format(pattern, getClass().getSimpleName(), leftEndpoint.toLeftString(),
+            rightEndpoint.toRightString(), step);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        if (!(obj instanceof AbstractRange<?, ?>)) {
+            return false;
+        }
+        final Range<?, ?> that = (Range<?, ?>) obj;
+        return new EqualsBuilder().append(getLeftEndpoint(), that.getLeftEndpoint())
+            .append(getRightEndpoint(), that.getRightEndpoint()).append(getStep(), that.getStep()).build();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int hashCode() {
+        int hash = getClass().getName().hashCode();
+        hash <<= 2;
+        hash ^= this.leftEndpoint.hashCode();
+        hash <<= 2;
+        hash ^= this.rightEndpoint.hashCode();
+        hash <<= 2;
+        hash ^= this.step.hashCode();
+        return hash;
+    }
+}

Modified: commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/CharacterRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/CharacterRange.java?rev=1540231&r1=1540230&r2=1540231&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/CharacterRange.java (original)
+++ commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/CharacterRange.java Sat Nov  9 00:29:42 2013
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.functor.range;
 
-import java.util.Collection;
 import java.util.Iterator;
 
 import org.apache.commons.functor.BinaryFunction;
@@ -28,7 +27,7 @@ import org.apache.commons.lang3.Validate
  * @since 1.0
  * @version $Revision$ $Date$
  */
-public final class CharacterRange implements Range<Character, Integer> {
+public final class CharacterRange extends AbstractRange<Character, Integer> {
 
     // attributes
     // ---------------------------------------------------------------
@@ -43,21 +42,6 @@ public final class CharacterRange implem
     public static final BoundType DEFAULT_RIGHT_BOUND_TYPE = BoundType.CLOSED;
 
     /**
-     * Left limit.
-     */
-    private final Endpoint<Character> leftEndpoint;
-
-    /**
-     * Right limit.
-     */
-    private final Endpoint<Character> rightEndpoint;
-
-    /**
-     * Increment step.
-     */
-    private final int step;
-
-    /**
      * Current value.
      */
     private char currentValue;
@@ -116,9 +100,7 @@ public final class CharacterRange implem
      * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public CharacterRange(Endpoint<Character> from, Endpoint<Character> to, int step) {
-        this.leftEndpoint = Validate.notNull(from, "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate.notNull(to, "Right Endpoint argument must not be null");
-        this.step = step;
+        super(from, to, Integer.valueOf(step));
         final char f = from.getValue();
         final char t = to.getValue();
 
@@ -161,26 +143,6 @@ public final class CharacterRange implem
 
     // range methods
     // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Character> getLeftEndpoint() {
-        return this.leftEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Character> getRightEndpoint() {
-        return this.rightEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Integer getStep() {
-        return Integer.valueOf(step);
-    }
 
     // iterable, iterator methods
     // ---------------------------------------------------------------
@@ -217,60 +179,10 @@ public final class CharacterRange implem
     /**
      * {@inheritDoc}
      */
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public Iterator<Character> iterator() {
         return this;
     }
 
-    // object methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String toString() {
-        return "CharacterRange<" + this.leftEndpoint.toLeftString() + ", "
-                + this.rightEndpoint.toRightString() + ", " + step + ">";
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof CharacterRange)) {
-            return false;
-        }
-        CharacterRange that = (CharacterRange) obj;
-        return this.leftEndpoint.equals(that.leftEndpoint)
-                && this.rightEndpoint.equals(that.rightEndpoint)
-                && this.step == that.step;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int hashCode() {
-        int hash = "CharacterRange".hashCode();
-        hash <<= 2;
-        hash ^= this.leftEndpoint.getValue();
-        hash <<= 2;
-        hash ^= this.rightEndpoint.getValue();
-        hash <<= 2;
-        hash ^= this.step;
-        return hash;
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -328,21 +240,4 @@ public final class CharacterRange implem
         return ((double) (value - firstValue) / step + 1) % 1.0 == 0.0;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean containsAll(Collection<Character> col) {
-        if (col == null || col.size() == 0) {
-            return Boolean.FALSE;
-        }
-        boolean r = Boolean.TRUE;
-        for (Character t : col) {
-            if (!this.contains(t)) {
-                r = Boolean.FALSE;
-                break;
-            }
-        }
-        return r;
-    }
-
 }

Modified: commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/DoubleRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/DoubleRange.java?rev=1540231&r1=1540230&r2=1540231&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/DoubleRange.java (original)
+++ commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/DoubleRange.java Sat Nov  9 00:29:42 2013
@@ -31,20 +31,6 @@ public class DoubleRange extends Numeric
 
     // attributes
     // ---------------------------------------------------------------
-    /**
-     * Left limit.
-     */
-    private final Endpoint<Double> leftEndpoint;
-
-    /**
-     * Right limit.
-     */
-    private final Endpoint<Double> rightEndpoint;
-
-    /**
-     * Increment step.
-     */
-    private final double step;
 
     /**
      * Current value.
@@ -140,9 +126,7 @@ public class DoubleRange extends Numeric
      * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public DoubleRange(Endpoint<Double> from, Endpoint<Double> to, double step) {
-        this.leftEndpoint = Validate.notNull(from, "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate.notNull(to, "Right Endpoint argument must not be null");
-        this.step = step;
+        super(from, to, Double.valueOf(step));
         final double f = from.getValue();
         final double t = to.getValue();
 
@@ -171,29 +155,7 @@ public class DoubleRange extends Numeric
         this(new Endpoint<Double>(from, leftBoundType), new Endpoint<Double>(to, rightBoundType), step);
     }
 
-    // range methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Double> getLeftEndpoint() {
-        return this.leftEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Double> getRightEndpoint() {
-        return this.rightEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Double getStep() {
-        return Double.valueOf(step);
-    }
- // iterable, iterator methods
+    // iterable, iterator methods
     // ---------------------------------------------------------------
     /**
      * {@inheritDoc}
@@ -228,58 +190,8 @@ public class DoubleRange extends Numeric
     /**
      * {@inheritDoc}
      */
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public Iterator<Double> iterator() {
         return this;
     }
 
-    // object methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String toString() {
-        return "DoubleRange<" + this.leftEndpoint.toLeftString() + ", "
-                + this.rightEndpoint.toRightString() + ", " + this.step + ">";
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof DoubleRange)) {
-            return false;
-        }
-        DoubleRange that = (DoubleRange) obj;
-        return this.leftEndpoint.equals(that.leftEndpoint)
-                && this.rightEndpoint.equals(that.rightEndpoint)
-                && this.step == that.step;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int hashCode() {
-        int hash = "DoubleRange".hashCode();
-        hash <<= 2;
-        hash ^= this.leftEndpoint.getValue().hashCode();
-        hash <<= 2;
-        hash ^= this.rightEndpoint.getValue().hashCode();
-        hash <<= 2;
-        hash ^= Double.valueOf(this.step).hashCode();
-        return hash;
-    }
-
 }

Modified: commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/FloatRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/FloatRange.java?rev=1540231&r1=1540230&r2=1540231&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/FloatRange.java (original)
+++ commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/FloatRange.java Sat Nov  9 00:29:42 2013
@@ -31,20 +31,6 @@ public class FloatRange extends NumericR
 
     // attributes
     // ---------------------------------------------------------------
-    /**
-     * Left limit.
-     */
-    private final Endpoint<Float> leftEndpoint;
-
-    /**
-     * Right limit.
-     */
-    private final Endpoint<Float> rightEndpoint;
-
-    /**
-     * Increment step.
-     */
-    private final float step;
 
     /**
      * Current value.
@@ -125,9 +111,7 @@ public class FloatRange extends NumericR
      * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public FloatRange(Endpoint<Float> from, Endpoint<Float> to, float step) {
-        this.leftEndpoint = Validate.notNull(from, "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate.notNull(to, "Right Endpoint argument must not be null");
-        this.step = step;
+        super(from, to, Float.valueOf(step));
         final float f = from.getValue();
         final float t = to.getValue();
 
@@ -170,29 +154,6 @@ public class FloatRange extends NumericR
         this(new Endpoint<Float>(from, leftBoundType), new Endpoint<Float>(to, rightBoundType), step);
     }
 
-    // range methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Float> getLeftEndpoint() {
-        return this.leftEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Float> getRightEndpoint() {
-        return this.rightEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Float getStep() {
-        return Float.valueOf(step);
-    }
-
     // iterable, iterator methods
     // ---------------------------------------------------------------
     /**
@@ -228,58 +189,8 @@ public class FloatRange extends NumericR
     /**
      * {@inheritDoc}
      */
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public Iterator<Float> iterator() {
         return this;
     }
 
-    // object methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String toString() {
-        return "FloatRange<" + this.leftEndpoint.toLeftString() + ", "
-                + this.rightEndpoint.toRightString() + ", " + this.step + ">";
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof FloatRange)) {
-            return false;
-        }
-        FloatRange that = (FloatRange) obj;
-        return this.leftEndpoint.equals(that.leftEndpoint)
-                && this.rightEndpoint.equals(that.rightEndpoint)
-                && this.step == that.step;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int hashCode() {
-        int hash = "FloatRange".hashCode();
-        hash <<= 2;
-        hash ^= this.leftEndpoint.getValue().hashCode();
-        hash <<= 2;
-        hash ^= this.rightEndpoint.getValue().hashCode();
-        hash <<= 2;
-        hash ^= Float.valueOf(this.step).hashCode();
-        return hash;
-    }
-
 }

Modified: commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/IntegerRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/IntegerRange.java?rev=1540231&r1=1540230&r2=1540231&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/IntegerRange.java (original)
+++ commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/IntegerRange.java Sat Nov  9 00:29:42 2013
@@ -31,20 +31,6 @@ public class IntegerRange extends Numeri
 
     // attributes
     // ---------------------------------------------------------------
-    /**
-     * Left limit.
-     */
-    private final Endpoint<Integer> leftEndpoint;
-
-    /**
-     * Right limit.
-     */
-    private final Endpoint<Integer> rightEndpoint;
-
-    /**
-     * Increment step.
-     */
-    private final int step;
 
     /**
      * Current value.
@@ -126,9 +112,7 @@ public class IntegerRange extends Numeri
      * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public IntegerRange(Endpoint<Integer> from, Endpoint<Integer> to, int step) {
-        this.leftEndpoint = Validate.notNull(from, "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate.notNull(to, "Right Endpoint argument must not be null");
-        this.step = step;
+        super(from, to, Integer.valueOf(step));
         final int f = from.getValue();
         final int t = to.getValue();
 
@@ -170,29 +154,6 @@ public class IntegerRange extends Numeri
         this(new Endpoint<Integer>(from, leftBoundType), new Endpoint<Integer>(to, rightBoundType), step);
     }
 
-    // range methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Integer> getLeftEndpoint() {
-        return this.leftEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Integer> getRightEndpoint() {
-        return this.rightEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Integer getStep() {
-        return Integer.valueOf(step);
-    }
-
     // iterable, iterator methods
     // ---------------------------------------------------------------
     /**
@@ -228,59 +189,8 @@ public class IntegerRange extends Numeri
     /**
      * {@inheritDoc}
      */
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public Iterator<Integer> iterator() {
         return this;
     }
 
-    // object methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String toString() {
-        return "IntegerRange<" + this.leftEndpoint.toLeftString()
-                + ", " + this.rightEndpoint.toRightString()
-                + ", " + this.step + ">";
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof IntegerRange)) {
-            return false;
-        }
-        IntegerRange that = (IntegerRange) obj;
-        return this.leftEndpoint.equals(that.leftEndpoint)
-                && this.rightEndpoint.equals(that.rightEndpoint)
-                && this.step == that.step;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int hashCode() {
-        int hash = "IntegerRange".hashCode();
-        hash <<= 2;
-        hash ^= this.leftEndpoint.getValue();
-        hash <<= 2;
-        hash ^= this.rightEndpoint.getValue();
-        hash <<= 2;
-        hash ^= this.step;
-        return hash;
-    }
-
 }

Modified: commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/LongRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/LongRange.java?rev=1540231&r1=1540230&r2=1540231&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/LongRange.java (original)
+++ commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/LongRange.java Sat Nov  9 00:29:42 2013
@@ -32,21 +32,6 @@ public final class LongRange extends Num
     //---------------------------------------------------------------
 
     /**
-     * Left limit.
-     */
-    private final Endpoint<Long> leftEndpoint;
-
-    /**
-     * Right limit.
-     */
-    private final Endpoint<Long> rightEndpoint;
-
-    /**
-     * Increment step.
-     */
-    private final long step;
-
-    /**
      * Current value.
      */
     private long currentValue;
@@ -150,9 +135,7 @@ public final class LongRange extends Num
      * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public LongRange(Endpoint<Long> from, Endpoint<Long> to, long step) {
-        this.leftEndpoint = Validate.notNull(from, "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate.notNull(to, "Right Endpoint argument must not be null");
-        this.step = step;
+        super(from, to, Long.valueOf(step));
         final long f = from.getValue();
         final long t = to.getValue();
 
@@ -181,29 +164,6 @@ public final class LongRange extends Num
         this(new Endpoint<Long>(from, leftBoundType), new Endpoint<Long>(to, rightBoundType), step);
     }
 
-    // range methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Long> getLeftEndpoint() {
-        return this.leftEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Endpoint<Long> getRightEndpoint() {
-        return this.rightEndpoint;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Long getStep() {
-        return Long.valueOf(step);
-    }
-
     // iterable, iterator methods
     // ---------------------------------------------------------------
     /**
@@ -239,58 +199,8 @@ public final class LongRange extends Num
     /**
      * {@inheritDoc}
      */
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public Iterator<Long> iterator() {
         return this;
     }
 
-    // object methods
-    // ---------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String toString() {
-        return "LongRange<" + this.leftEndpoint.toLeftString() + ", "
-                + this.rightEndpoint.toRightString() + ", " + step + ">";
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof LongRange)) {
-            return false;
-        }
-        LongRange that = (LongRange) obj;
-        return this.leftEndpoint.equals(that.leftEndpoint)
-                && this.rightEndpoint.equals(that.rightEndpoint)
-                && this.step == that.step;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int hashCode() {
-        int hash = "LongRange".hashCode();
-        hash <<= 2;
-        hash ^= this.leftEndpoint.getValue();
-        hash <<= 2;
-        hash ^= this.rightEndpoint.getValue();
-        hash <<= 2;
-        hash ^= this.step;
-        return hash;
-    }
-
 }

Modified: commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/NumericRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/NumericRange.java?rev=1540231&r1=1540230&r2=1540231&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/NumericRange.java (original)
+++ commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/NumericRange.java Sat Nov  9 00:29:42 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.functor.range;
 
-import java.util.Collection;
-
 /**
  * A base class for numeric ranges. The elements within this range must be a
  * <b>Number</b> and <b>Comparable</b>.
@@ -31,7 +29,17 @@ import java.util.Collection;
  * @since 0.1
  * @version $Revision$ $Date$
  */
-public abstract class NumericRange<T extends Number & Comparable<?>> implements Range<T, T> {
+public abstract class NumericRange<T extends Number & Comparable<?>> extends AbstractRange<T, T> {
+
+    /**
+     * Construct a new {@link NumericRange}.
+     * @param leftEndpoint
+     * @param rightEndpoint
+     * @param step
+     */
+    protected NumericRange(Endpoint<T> leftEndpoint, Endpoint<T> rightEndpoint, T step) {
+        super(leftEndpoint, rightEndpoint, step);
+    }
 
     /**
      * {@inheritDoc}
@@ -92,19 +100,4 @@ public abstract class NumericRange<T ext
         return ((value - firstValue) / step + 1) % 1.0 == 0.0;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean containsAll(Collection<T> col) {
-        if (col == null || col.isEmpty()) {
-            return false;
-        }
-        for (T t : col) {
-            if (!contains(t)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
 }