commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1533913 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/BooleanUtils.java test/java/org/apache/commons/lang3/BooleanUtilsTest.java
Date Sun, 20 Oct 2013 14:31:24 GMT
Author: britter
Date: Sun Oct 20 14:31:24 2013
New Revision: 1533913

URL: http://svn.apache.org/r1533913
Log:
Use less confusing method name

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java?rev=1533913&r1=1533912&r2=1533913&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java Sun
Oct 20 14:31:24 2013
@@ -145,12 +145,12 @@ public class BooleanUtils {
      * <p>Checks if exactly one of the given booleans is true.</p>
      *
      * <pre>
-     *   BooleanUtils.isOneTrue(true, true)   = false
-     *   BooleanUtils.isOneTrue(false, false) = false
-     *   BooleanUtils.isOneTrue(true, false)  = true
-     *   BooleanUtils.isOneTrue(true, true)   = false
-     *   BooleanUtils.isOneTrue(false, false) = false
-     *   BooleanUtils.isOneTrue(true, false)  = true
+     *   BooleanUtils.isExactlyOneTrue(true, true)   = false
+     *   BooleanUtils.isExactlyOneTrue(false, false) = false
+     *   BooleanUtils.isExactlyOneTrue(true, false)  = true
+     *   BooleanUtils.isExactlyOneTrue(true, true)   = false
+     *   BooleanUtils.isExactlyOneTrue(false, false) = false
+     *   BooleanUtils.isExactlyOneTrue(true, false)  = true
      * </pre>
      *
      * @param array  an array of {@code boolean}s
@@ -159,7 +159,7 @@ public class BooleanUtils {
      * @throws IllegalArgumentException if {@code array} is empty.
      * @since 3.2
      */
-    public static boolean isOneTrue(final boolean... array) {
+    public static boolean isExactlyOneTrue(final boolean... array) {
         // Validates input
         if (array == null) {
             throw new IllegalArgumentException("The Array must not be null");
@@ -172,7 +172,7 @@ public class BooleanUtils {
         int trueCount = 0;
         for (final boolean element : array) {
             // If item is true, and trueCount is < 1, increments count
-            // Else, isOneTrue fails
+            // Else, isExactlyOneTrue fails
             if (element) {
                 if (trueCount < 1) {
                     trueCount++;
@@ -190,9 +190,9 @@ public class BooleanUtils {
      * <p>Checks if exactly one of the given Booleans is true.</p>
      *
      * <pre>
-     *   BooleanUtils.isOneTrue(new Boolean[] { Boolean.TRUE, Boolean.TRUE })   = Boolean.FALSE
-     *   BooleanUtils.isOneTrue(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) = Boolean.FALSE
-     *   BooleanUtils.isOneTrue(new Boolean[] { Boolean.TRUE, Boolean.FALSE })  = Boolean.TRUE
+     *   BooleanUtils.isExactlyOneTrue(new Boolean[] { Boolean.TRUE, Boolean.TRUE })   =
Boolean.FALSE
+     *   BooleanUtils.isExactlyOneTrue(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) =
Boolean.FALSE
+     *   BooleanUtils.isExactlyOneTrue(new Boolean[] { Boolean.TRUE, Boolean.FALSE })  =
Boolean.TRUE
      * </pre>
      *
      * @param array  an array of {@code Boolean}s
@@ -202,7 +202,7 @@ public class BooleanUtils {
      * @throws IllegalArgumentException if {@code array} contains a {@code null}
      * @since 3.2
      */
-    public static Boolean isOneTrue(final Boolean... array) {
+    public static Boolean isExactlyOneTrue(final Boolean... array) {
         if (array == null) {
             throw new IllegalArgumentException("The Array must not be null");
         }
@@ -211,7 +211,7 @@ public class BooleanUtils {
         }
         try {
             final boolean[] primitive = ArrayUtils.toPrimitive(array);
-            return isOneTrue(primitive) ? Boolean.TRUE : Boolean.FALSE;
+            return isExactlyOneTrue(primitive) ? Boolean.TRUE : Boolean.FALSE;
         } catch (final NullPointerException ex) {
             throw new IllegalArgumentException("The array must not contain any null elements");
         }

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java?rev=1533913&r1=1533912&r2=1533913&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
Sun Oct 20 14:31:24 2013
@@ -53,186 +53,186 @@ public class BooleanUtilsTest {
         assertSame(Boolean.FALSE, BooleanUtils.negate(Boolean.TRUE));
     }
 
-    //  test isOneTrue
+    //  test isExactlyOneTrue
     //  -----------------------------------------------------------------------
     @Test(expected = IllegalArgumentException.class)
-    public void testIsOneTrue_primitive_nullInput() {
-        BooleanUtils.isOneTrue((boolean[]) null);
+    public void testIsExactlyOneTrue_primitive_nullInput() {
+        BooleanUtils.isExactlyOneTrue((boolean[]) null);
     }
 
     @Test(expected = IllegalArgumentException.class)
-    public void testIsOneTrue_primitive_emptyInput() {
-        BooleanUtils.isOneTrue(new boolean[] {});
+    public void testIsExactlyOneTrue_primitive_emptyInput() {
+        BooleanUtils.isExactlyOneTrue(new boolean[]{});
     }
 
     @Test
-    public void testIsOneTrue_primitive_validInput_2items() {
+    public void testIsExactlyOneTrue_primitive_validInput_2items() {
         assertFalse(
                 "true, true",
-                BooleanUtils.isOneTrue(new boolean[] { true, true }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{true, true}));
 
         assertFalse(
                 "false, false",
-                BooleanUtils.isOneTrue(new boolean[] { false, false }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{false, false}));
 
         assertTrue(
                 "true, false",
-                BooleanUtils.isOneTrue(new boolean[] { true, false }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{true, false}));
 
         assertTrue(
                 "false, true",
-                BooleanUtils.isOneTrue(new boolean[] { false, true }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{false, true}));
     }
 
     @Test
-    public void testIsOneTrue_primitive_validInput_3items() {
+    public void testIsExactlyOneTrue_primitive_validInput_3items() {
         assertFalse(
                 "false, false, false",
-                BooleanUtils.isOneTrue(new boolean[] { false, false, false }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{false, false, false}));
 
         assertTrue(
                 "false, false, true",
-                BooleanUtils.isOneTrue(new boolean[] { false, false, true }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{false, false, true}));
 
         assertTrue(
                 "false, true, false",
-                BooleanUtils.isOneTrue(new boolean[] { false, true, false }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{false, true, false}));
 
         assertFalse(
                 "false, true, true",
-                BooleanUtils.isOneTrue(new boolean[] { false, true, true }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{false, true, true}));
 
         assertTrue(
                 "true, false, false",
-                BooleanUtils.isOneTrue(new boolean[] { true, false, false }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{true, false, false}));
 
         assertFalse(
                 "true, false, true",
-                BooleanUtils.isOneTrue(new boolean[] { true, false, true }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{true, false, true}));
 
         assertFalse(
                 "true, true, false",
-                BooleanUtils.isOneTrue(new boolean[] { true, true, false }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{true, true, false}));
 
         assertFalse(
                 "true, true, true",
-                BooleanUtils.isOneTrue(new boolean[] { true, true, true }));
+                BooleanUtils.isExactlyOneTrue(new boolean[]{true, true, true}));
     }
 
     @Test(expected = IllegalArgumentException.class)
-    public void testIsOneTrue_object_nullInput() {
-        BooleanUtils.isOneTrue((Boolean[]) null);
+    public void testIsExactlyOneTrue_object_nullInput() {
+        BooleanUtils.isExactlyOneTrue((Boolean[]) null);
     }
 
     @Test(expected = IllegalArgumentException.class)
-    public void testIsOneTrue_object_emptyInput() {
-        BooleanUtils.isOneTrue(new Boolean[] {});
+    public void testIsExactlyOneTrue_object_emptyInput() {
+        BooleanUtils.isExactlyOneTrue(new Boolean[]{});
     }
 
     @Test(expected = IllegalArgumentException.class)
-    public void testIsOneTrue_object_nullElementInput() {
-        BooleanUtils.isOneTrue(new Boolean[] {null});
+    public void testIsExactlyOneTrue_object_nullElementInput() {
+        BooleanUtils.isExactlyOneTrue(new Boolean[]{null});
     }
 
     @Test
-    public void testIsOneTrue_object_validInput_2items() {
+    public void testIsExactlyOneTrue_object_validInput_2items() {
         assertFalse(
                 "false, false",
                 BooleanUtils
-                        .isOneTrue(new Boolean[] { Boolean.FALSE, Boolean.FALSE })
+                        .isExactlyOneTrue(new Boolean[]{Boolean.FALSE, Boolean.FALSE})
                         .booleanValue());
 
         assertTrue(
                 "false, true",
                 BooleanUtils
-                        .isOneTrue(new Boolean[] { Boolean.FALSE, Boolean.TRUE })
+                        .isExactlyOneTrue(new Boolean[]{Boolean.FALSE, Boolean.TRUE})
                         .booleanValue());
 
         assertTrue(
                 "true, false",
                 BooleanUtils
-                        .isOneTrue(new Boolean[] { Boolean.TRUE, Boolean.FALSE })
+                        .isExactlyOneTrue(new Boolean[]{Boolean.TRUE, Boolean.FALSE})
                         .booleanValue());
 
         assertFalse(
                 "true, true",
                 BooleanUtils
-                        .isOneTrue(new Boolean[] { Boolean.TRUE, Boolean.TRUE })
+                        .isExactlyOneTrue(new Boolean[]{Boolean.TRUE, Boolean.TRUE})
                         .booleanValue());
     }
 
     @Test
-    public void testIsOneTrue_object_validInput_3items() {
+    public void testIsExactlyOneTrue_object_validInput_3items() {
         assertFalse(
                 "false, false, false",
-                BooleanUtils.isOneTrue(
-                        new Boolean[] {
+                BooleanUtils.isExactlyOneTrue(
+                        new Boolean[]{
                                 Boolean.FALSE,
                                 Boolean.FALSE,
-                                Boolean.FALSE })
+                                Boolean.FALSE})
                         .booleanValue());
 
         assertTrue(
                 "false, false, true",
                 BooleanUtils
-                        .isOneTrue(
-                                new Boolean[] {
+                        .isExactlyOneTrue(
+                                new Boolean[]{
                                         Boolean.FALSE,
                                         Boolean.FALSE,
-                                        Boolean.TRUE })
+                                        Boolean.TRUE})
                         .booleanValue());
 
         assertTrue(
                 "false, true, false",
                 BooleanUtils
-                        .isOneTrue(
-                                new Boolean[] {
+                        .isExactlyOneTrue(
+                                new Boolean[]{
                                         Boolean.FALSE,
                                         Boolean.TRUE,
-                                        Boolean.FALSE })
+                                        Boolean.FALSE})
                         .booleanValue());
 
         assertTrue(
                 "true, false, false",
                 BooleanUtils
-                        .isOneTrue(
-                                new Boolean[] {
+                        .isExactlyOneTrue(
+                                new Boolean[]{
                                         Boolean.TRUE,
                                         Boolean.FALSE,
-                                        Boolean.FALSE })
+                                        Boolean.FALSE})
                         .booleanValue());
 
         assertFalse(
                 "true, false, true",
-                BooleanUtils.isOneTrue(
-                        new Boolean[] {
+                BooleanUtils.isExactlyOneTrue(
+                        new Boolean[]{
                                 Boolean.TRUE,
                                 Boolean.FALSE,
-                                Boolean.TRUE })
+                                Boolean.TRUE})
                         .booleanValue());
 
         assertFalse(
                 "true, true, false",
-                BooleanUtils.isOneTrue(
-                        new Boolean[] {
+                BooleanUtils.isExactlyOneTrue(
+                        new Boolean[]{
                                 Boolean.TRUE,
                                 Boolean.TRUE,
-                                Boolean.FALSE })
+                                Boolean.FALSE})
                         .booleanValue());
 
         assertFalse(
                 "false, true, true",
-                BooleanUtils.isOneTrue(
-                        new Boolean[] {
+                BooleanUtils.isExactlyOneTrue(
+                        new Boolean[]{
                                 Boolean.FALSE,
                                 Boolean.TRUE,
-                                Boolean.TRUE })
+                                Boolean.TRUE})
                         .booleanValue());
 
         assertFalse(
                 "true, true, true",
                 BooleanUtils
-                        .isOneTrue(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE
})
+                        .isExactlyOneTrue(new Boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.TRUE})
                         .booleanValue());
     }
 



Mime
View raw message