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/01/27 19:08:13 UTC

svn commit: r1439133 - in /commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range: CharacterRange.java NumericRange.java

Author: mbenson
Date: Sun Jan 27 18:08:12 2013
New Revision: 1439133

URL: http://svn.apache.org/viewvc?rev=1439133&view=rev
Log:
use primitives where warranted; simplify some loops

Modified:
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java?rev=1439133&r1=1439132&r2=1439133&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java Sun Jan 27 18:08:12 2013
@@ -273,7 +273,7 @@ public final class CharacterRange extend
      */
     public boolean contains(Character obj) {
         if (obj == null) {
-            return Boolean.FALSE;
+            return false;
         }
         char leftValue = this.getLeftEndpoint().getValue().charValue();
         char rightValue = this.getRightEndpoint().getValue().charValue();
@@ -289,13 +289,13 @@ public final class CharacterRange extend
             firstValue = includeLeft ? leftValue : leftValue + step;
             lastValue = includeRight ? rightValue : rightValue + 1;
             if (value > firstValue || value < lastValue) {
-                return Boolean.FALSE;
+                return false;
             }
         } else {
             firstValue = includeLeft ? leftValue : leftValue + step;
             lastValue = includeRight ? rightValue : rightValue - 1;
             if (value < firstValue || value > lastValue) {
-                return Boolean.FALSE;
+                return false;
             }
         }
         return ((double) (value - firstValue) / step + 1) % 1.0 == 0.0;
@@ -306,16 +306,14 @@ public final class CharacterRange extend
      */
     public boolean containsAll(Collection<Character> col) {
         if (col == null || col.size() == 0) {
-            return Boolean.FALSE;
+            return false;
         }
-        boolean r = Boolean.TRUE;
         for (Character t : col) {
             if (!this.contains(t)) {
-                r = Boolean.FALSE;
-                break;
+                return false;
             }
         }
-        return r;
+        return true;
     }
 
 }

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java?rev=1439133&r1=1439132&r2=1439133&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java Sun Jan 27 18:08:12 2013
@@ -46,7 +46,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) {
@@ -65,7 +65,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();
@@ -81,7 +81,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;
@@ -89,7 +89,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;
@@ -100,16 +100,14 @@ public abstract class NumericRange<T ext
      */
     public boolean containsAll(Collection<T> col) {
         if (col == null || col.size() == 0) {
-            return Boolean.FALSE;
+            return false;
         }
-        boolean r = Boolean.TRUE;
         for (T t : col) {
             if (!this.contains(t)) {
-                r = Boolean.FALSE;
-                break;
+                return false;
             }
         }
-        return r;
+        return true;
     }
 
 }