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/08 01:04:42 UTC

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

Author: mbenson
Date: Fri Nov  8 00:04:42 2013
New Revision: 1539869

URL: http://svn.apache.org/r1539869
Log:
improvements in the range package

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/Endpoint.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

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=1539869&r1=1539868&r2=1539869&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 Fri Nov  8 00:04:42 2013
@@ -101,10 +101,10 @@ public final class CharacterRange implem
      *
      * @param from start
      * @param to end
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public CharacterRange(Endpoint<Character> from, Endpoint<Character> to) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(),
-                DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
+        this(from, to, DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
     }
 
     /**
@@ -113,9 +113,23 @@ public final class CharacterRange implem
      * @param from start
      * @param to end
      * @param step increment
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public CharacterRange(Endpoint<Character> from, Endpoint<Character> to, int step) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(), 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;
+        final char f = from.getValue();
+        final char t = to.getValue();
+
+        Validate.isTrue(f == t || Integer.signum(step) == Integer.signum(t - f),
+            "Will never reach '%s' from '%s' using step %s", t, f, step);
+
+        if (from.getBoundType() == BoundType.CLOSED) {
+            this.currentValue = f;
+        } else {
+            this.currentValue = (char) (f + step);
+        }
     }
 
     /**
@@ -125,9 +139,9 @@ public final class CharacterRange implem
      * @param leftBoundType type of left bound
      * @param to end
      * @param rightBoundType type of right bound
+     * @throws NullPointerException if either bound type is {@code null}
      */
-    public CharacterRange(char from, BoundType leftBoundType, char to,
-                        BoundType rightBoundType) {
+    public CharacterRange(char from, BoundType leftBoundType, char to, BoundType rightBoundType) {
         this(from, leftBoundType, to, rightBoundType, DEFAULT_STEP.evaluate(from, to));
     }
 
@@ -139,27 +153,12 @@ public final class CharacterRange implem
      * @param to end
      * @param rightBoundType type of right bound
      * @param step increment
+     * @throws NullPointerException if either bound type is {@code null}
      */
-    public CharacterRange(char from, BoundType leftBoundType, char to,
-                          BoundType rightBoundType, int step) {
-        this.leftEndpoint = Validate
-            .notNull(new Endpoint<Character>(from, leftBoundType),
-                     "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate
-            .notNull(new Endpoint<Character>(to, rightBoundType),
-                     "Right Endpoint argument must not be null");
-        this.step = step;
-        if (from != to && Integer.signum(step) != Integer.signum(to - from)) {
-            throw new IllegalArgumentException("Will never reach " + to
-                                               + " from " + from
-                                               + " using step " + step);
-        }
-        if (this.leftEndpoint.getBoundType() == BoundType.CLOSED) {
-            this.currentValue = this.leftEndpoint.getValue();
-        } else {
-            this.currentValue = (char) (this.leftEndpoint.getValue() + this.step);
-        }
+    public CharacterRange(char from, BoundType leftBoundType, char to, BoundType rightBoundType, int step) {
+        this(new Endpoint<Character>(from, leftBoundType), new Endpoint<Character>(to, rightBoundType), step);
     }
+
     // range methods
     // ---------------------------------------------------------------
     /**
@@ -180,7 +179,7 @@ public final class CharacterRange implem
      * {@inheritDoc}
      */
     public Integer getStep() {
-        return this.step;
+        return Integer.valueOf(step);
     }
 
     // iterable, iterator methods
@@ -212,7 +211,7 @@ public final class CharacterRange implem
         final int step = this.getStep();
         final char r = this.currentValue;
         this.currentValue += step;
-        return r;
+        return Character.valueOf(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=1539869&r1=1539868&r2=1539869&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 Fri Nov  8 00:04:42 2013
@@ -111,10 +111,10 @@ public class DoubleRange extends Numeric
      *
      * @param from start
      * @param to end
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public DoubleRange(Endpoint<Double> from, Endpoint<Double> to) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(),
-                DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
+        this(from, to, DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
     }
 
     /**
@@ -124,6 +124,7 @@ public class DoubleRange extends Numeric
      * @param leftBoundType type of left bound
      * @param to end
      * @param rightBoundType type of right bound
+     * @throws NullPointerException if either bound type is {@code null}
      */
     public DoubleRange(double from, BoundType leftBoundType, double to,
                         BoundType rightBoundType) {
@@ -136,9 +137,23 @@ public class DoubleRange extends Numeric
      * @param from start
      * @param to end
      * @param step increment
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public DoubleRange(Endpoint<Double> from, Endpoint<Double> to, double step) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(), 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;
+        final double f = from.getValue();
+        final double t = to.getValue();
+
+        Validate.isTrue(f == t || Math.signum(step) == Math.signum(t - f),
+            "Will never reach '%s' from '%s' using step %s", t, f, step);
+
+        if (from.getBoundType() == BoundType.CLOSED) {
+            this.currentValue = f;
+        } else {
+            this.currentValue = f + step;
+        }
     }
 
     /**
@@ -149,26 +164,11 @@ public class DoubleRange extends Numeric
      * @param to end
      * @param rightBoundType type of right bound
      * @param step increment
+     * @throws NullPointerException if either bound type is {@code null}
      */
     public DoubleRange(double from, BoundType leftBoundType, double to,
                        BoundType rightBoundType, double step) {
-        this.leftEndpoint = Validate
-            .notNull(new Endpoint<Double>(from, leftBoundType),
-                     "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate
-            .notNull(new Endpoint<Double>(to, rightBoundType),
-                     "Right Endpoint argument must not be null");
-        this.step = step;
-        if (from != to && Math.signum(step) != Math.signum(to - from)) {
-            throw new IllegalArgumentException("Will never reach " + to
-                                               + " from " + from
-                                               + " using step " + step);
-        }
-        if (this.leftEndpoint.getBoundType() == BoundType.CLOSED) {
-            this.currentValue = this.leftEndpoint.getValue();
-        } else {
-            this.currentValue = this.leftEndpoint.getValue() + this.step;
-        }
+        this(new Endpoint<Double>(from, leftBoundType), new Endpoint<Double>(to, rightBoundType), step);
     }
 
     // range methods
@@ -191,7 +191,7 @@ public class DoubleRange extends Numeric
      * {@inheritDoc}
      */
     public Double getStep() {
-        return this.step;
+        return Double.valueOf(step);
     }
  // iterable, iterator methods
     // ---------------------------------------------------------------
@@ -222,7 +222,7 @@ public class DoubleRange extends Numeric
         final double step = this.getStep();
         final double r = this.currentValue;
         this.currentValue += step;
-        return r;
+        return Double.valueOf(r);
     }
 
     /**

Modified: commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/Endpoint.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/Endpoint.java?rev=1539869&r1=1539868&r2=1539869&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/Endpoint.java (original)
+++ commons/proper/functor/trunk/core/src/main/java/org/apache/commons/functor/range/Endpoint.java Fri Nov  8 00:04:42 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.functor.range;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * Represent an endpoint of a range. This can be the left endpoint or the right
  * endpoint. It is also called left limit or right limit, and can be open
@@ -45,7 +47,7 @@ public class Endpoint<T extends Comparab
      */
     public Endpoint(T value, BoundType boundType) {
         this.value = value;
-        this.boundType = boundType;
+        this.boundType = Validate.notNull(boundType, "bound type must not be null");
     }
 
     /**

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=1539869&r1=1539868&r2=1539869&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 Fri Nov  8 00:04:42 2013
@@ -110,10 +110,10 @@ public class FloatRange extends NumericR
      *
      * @param from start
      * @param to end
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public FloatRange(Endpoint<Float> from, Endpoint<Float> to) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(),
-                DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
+        this(from, to, DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
     }
 
     /**
@@ -122,9 +122,23 @@ public class FloatRange extends NumericR
      * @param from start
      * @param to end
      * @param step increment
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public FloatRange(Endpoint<Float> from, Endpoint<Float> to, float step) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(), 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;
+        final float f = from.getValue();
+        final float t = to.getValue();
+
+        Validate.isTrue(f == t || Math.signum(step) == Math.signum(t - f),
+            "Will never reach '%s' from '%s' using step %s", t, f, step);
+
+        if (from.getBoundType() == BoundType.CLOSED) {
+            this.currentValue = f;
+        } else {
+            this.currentValue = f + step;
+        }
     }
 
     /**
@@ -134,6 +148,7 @@ public class FloatRange extends NumericR
      * @param leftBoundType type of left bound
      * @param to end
      * @param rightBoundType type of right bound
+     * @throws NullPointerException if either bound type is {@code null}
      */
     public FloatRange(float from, BoundType leftBoundType, float to,
                         BoundType rightBoundType) {
@@ -148,26 +163,11 @@ public class FloatRange extends NumericR
      * @param to end
      * @param rightBoundType type of right bound
      * @param step increment
+     * @throws NullPointerException if either bound type is {@code null}
      */
     public FloatRange(float from, BoundType leftBoundType, float to,
                       BoundType rightBoundType, float step) {
-        this.leftEndpoint = Validate
-            .notNull(new Endpoint<Float>(from, leftBoundType),
-                     "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate
-            .notNull(new Endpoint<Float>(to, rightBoundType),
-                     "Right Endpoint argument must not be null");
-        this.step = step;
-        if (from != to && Math.signum(step) != Math.signum(to - from)) {
-            throw new IllegalArgumentException("Will never reach " + to
-                                               + " from " + from
-                                               + " using step " + step);
-        }
-        if (this.leftEndpoint.getBoundType() == BoundType.CLOSED) {
-            this.currentValue = this.leftEndpoint.getValue();
-        } else {
-            this.currentValue = this.leftEndpoint.getValue() + this.step;
-        }
+        this(new Endpoint<Float>(from, leftBoundType), new Endpoint<Float>(to, rightBoundType), step);
     }
 
     // range methods
@@ -190,7 +190,7 @@ public class FloatRange extends NumericR
      * {@inheritDoc}
      */
     public Float getStep() {
-        return this.step;
+        return Float.valueOf(step);
     }
 
     // iterable, iterator methods
@@ -222,7 +222,7 @@ public class FloatRange extends NumericR
         final float step = this.getStep();
         final float r = this.currentValue;
         this.currentValue += step;
-        return r;
+        return Float.valueOf(r);
     }
 
     /**

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=1539869&r1=1539868&r2=1539869&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 Fri Nov  8 00:04:42 2013
@@ -111,10 +111,10 @@ public class IntegerRange extends Numeri
      *
      * @param from start
      * @param to end
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public IntegerRange(Endpoint<Integer> from, Endpoint<Integer> to) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(),
-                DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
+        this(from, to, DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
     }
 
     /**
@@ -123,9 +123,23 @@ public class IntegerRange extends Numeri
      * @param from start
      * @param to end
      * @param step increment
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public IntegerRange(Endpoint<Integer> from, Endpoint<Integer> to, int step) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(), 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;
+        final int f = from.getValue();
+        final int t = to.getValue();
+
+        Validate.isTrue(f == t || Integer.signum(step) == Integer.signum(t - f),
+            "Will never reach '%s' from '%s' using step %s", t, f, step);
+
+        if (from.getBoundType() == BoundType.CLOSED) {
+            this.currentValue = f;
+        } else {
+            this.currentValue = f + step;
+        }
     }
 
     /**
@@ -135,6 +149,7 @@ public class IntegerRange extends Numeri
      * @param leftBoundType type of left bound
      * @param to end
      * @param rightBoundType type of right bound
+     * @throws NullPointerException if either {@link BoundType} is {@code null}
      */
     public IntegerRange(int from, BoundType leftBoundType, int to,
                         BoundType rightBoundType) {
@@ -149,26 +164,10 @@ public class IntegerRange extends Numeri
      * @param to end
      * @param rightBoundType type of right bound
      * @param step increment
+     * @throws NullPointerException if either {@link BoundType} is {@code null}
      */
-    public IntegerRange(int from, BoundType leftBoundType, int to,
-                        BoundType rightBoundType, int step) {
-        this.leftEndpoint = Validate
-            .notNull(new Endpoint<Integer>(from, leftBoundType),
-                     "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate
-            .notNull(new Endpoint<Integer>(to, rightBoundType),
-                     "Right Endpoint argument must not be null");
-        this.step = step;
-        if (from != to && Integer.signum(step) != Integer.signum(to - from)) {
-            throw new IllegalArgumentException("Will never reach " + to
-                                               + " from " + from
-                                               + " using step " + step);
-        }
-        if (this.leftEndpoint.getBoundType() == BoundType.CLOSED) {
-            this.currentValue = this.leftEndpoint.getValue();
-        } else {
-            this.currentValue = this.leftEndpoint.getValue() + this.step;
-        }
+    public IntegerRange(int from, BoundType leftBoundType, int to, BoundType rightBoundType, int step) {
+        this(new Endpoint<Integer>(from, leftBoundType), new Endpoint<Integer>(to, rightBoundType), step);
     }
 
     // range methods
@@ -191,7 +190,7 @@ public class IntegerRange extends Numeri
      * {@inheritDoc}
      */
     public Integer getStep() {
-        return this.step;
+        return Integer.valueOf(step);
     }
 
     // iterable, iterator methods
@@ -223,7 +222,7 @@ public class IntegerRange extends Numeri
         final int step = this.getStep();
         final int r = this.currentValue;
         this.currentValue += step;
-        return r;
+        return Integer.valueOf(r);
     }
 
     /**

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=1539869&r1=1539868&r2=1539869&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 Fri Nov  8 00:04:42 2013
@@ -110,10 +110,10 @@ public final class LongRange extends Num
      *
      * @param from start
      * @param to end
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public LongRange(Endpoint<Long> from, Endpoint<Long> to) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(),
-                DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
+        this(from, to, DEFAULT_STEP.evaluate(from.getValue(), to.getValue()));
     }
 
     /**
@@ -122,12 +122,12 @@ public final class LongRange extends Num
      * @param from start
      * @param to end
      * @param step increment
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public LongRange(Endpoint<Long> from, Endpoint<Long> to, int step) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(), step);
+        this(from, to, (long) step);
     }
 
-
     /**
      * Create a new LongRange.
      *
@@ -135,9 +135,9 @@ public final class LongRange extends Num
      * @param leftBoundType type of left bound
      * @param to end
      * @param rightBoundType type of right bound
+     * @throws NullPointerException if either {@link BoundType} is {@code null}
      */
-    public LongRange(long from, BoundType leftBoundType, long to,
-                        BoundType rightBoundType) {
+    public LongRange(long from, BoundType leftBoundType, long to, BoundType rightBoundType) {
         this(from, leftBoundType, to, rightBoundType, DEFAULT_STEP.evaluate(from, to));
     }
 
@@ -147,9 +147,23 @@ public final class LongRange extends Num
      * @param from start
      * @param to end
      * @param step increment
+     * @throws NullPointerException if either {@link Endpoint} is {@code null}
      */
     public LongRange(Endpoint<Long> from, Endpoint<Long> to, long step) {
-        this(from.getValue(), from.getBoundType(), to.getValue(), to.getBoundType(), 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;
+        final long f = from.getValue();
+        final long t = to.getValue();
+
+        Validate.isTrue(f == t || Long.signum(step) == Long.signum(t - f),
+            "Will never reach '%s' from '%s' using step %s", t, f, step);
+
+        if (from.getBoundType() == BoundType.CLOSED) {
+            this.currentValue = f;
+        } else {
+            this.currentValue = f + step;
+        }
     }
 
     /**
@@ -160,26 +174,11 @@ public final class LongRange extends Num
      * @param to end
      * @param rightBoundType type of right bound
      * @param step increment
+     * @throws NullPointerException if either {@link BoundType} is {@code null}
      */
     public LongRange(long from, BoundType leftBoundType, long to,
                      BoundType rightBoundType, long step) {
-        this.leftEndpoint = Validate
-            .notNull(new Endpoint<Long>(from, leftBoundType),
-                     "Left Endpoint argument must not be null");
-        this.rightEndpoint = Validate
-            .notNull(new Endpoint<Long>(to, rightBoundType),
-                     "Right Endpoint argument must not be null");
-        this.step = step;
-        if (from != to && Long.signum(step) != Long.signum(to - from)) {
-            throw new IllegalArgumentException("Will never reach " + to
-                                               + " from " + from
-                                               + " using step " + step);
-        }
-        if (this.leftEndpoint.getBoundType() == BoundType.CLOSED) {
-            this.currentValue = this.leftEndpoint.getValue();
-        } else {
-            this.currentValue = this.leftEndpoint.getValue() + this.step;
-        }
+        this(new Endpoint<Long>(from, leftBoundType), new Endpoint<Long>(to, rightBoundType), step);
     }
 
     // range methods
@@ -202,7 +201,7 @@ public final class LongRange extends Num
      * {@inheritDoc}
      */
     public Long getStep() {
-        return this.step;
+        return Long.valueOf(step);
     }
 
     // iterable, iterator methods
@@ -234,7 +233,7 @@ public final class LongRange extends Num
         final long step = this.getStep();
         final long r = this.currentValue;
         this.currentValue += step;
-        return r;
+        return Long.valueOf(r);
     }
 
     /**

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=1539869&r1=1539868&r2=1539869&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 Fri Nov  8 00:04:42 2013
@@ -43,7 +43,7 @@ public abstract class NumericRange<T ext
         boolean closedRight = this.getRightEndpoint().getBoundType() == BoundType.CLOSED;
         if (!closedLeft && !closedRight
              && this.getLeftEndpoint().equals(this.getRightEndpoint())) {
-            return Boolean.TRUE;
+            return true;
         }
         double step = this.getStep().doubleValue();
         if (step > 0.0) {
@@ -62,7 +62,7 @@ public abstract class NumericRange<T ext
      */
     public boolean contains(T obj) {
         if (obj == null) {
-            return Boolean.FALSE;
+            return false;
         }
         double leftValue = this.getLeftEndpoint().getValue().doubleValue();
         double rightValue = this.getRightEndpoint().getValue().doubleValue();
@@ -78,7 +78,7 @@ public abstract class NumericRange<T ext
             firstValue = includeLeft ? leftValue : leftValue + step;
             lastValue = includeRight ? rightValue : Math.nextUp(rightValue);
             if (value > firstValue || value < lastValue) {
-                return Boolean.FALSE;
+                return false;
             }
         } else {
             firstValue = includeLeft ? leftValue : leftValue + step;
@@ -86,7 +86,7 @@ public abstract class NumericRange<T ext
                                                     - (rightValue - Math
                                                         .nextUp(rightValue));
             if (value < firstValue || value > lastValue) {
-                return Boolean.FALSE;
+                return false;
             }
         }
         return ((value - firstValue) / step + 1) % 1.0 == 0.0;
@@ -96,17 +96,15 @@ public abstract class NumericRange<T ext
      * {@inheritDoc}
      */
     public boolean containsAll(Collection<T> col) {
-        if (col == null || col.size() == 0) {
-            return Boolean.FALSE;
+        if (col == null || col.isEmpty()) {
+            return false;
         }
-        boolean r = Boolean.TRUE;
         for (T t : col) {
-            if (!this.contains(t)) {
-                r = Boolean.FALSE;
-                break;
+            if (!contains(t)) {
+                return false;
             }
         }
-        return r;
+        return true;
     }
 
 }