commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject [3/3] [lang] Make sure placement of curly braces is consistent
Date Tue, 06 Jun 2017 20:14:58 GMT
Make sure placement of curly braces is consistent


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/309b34f0
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/309b34f0
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/309b34f0

Branch: refs/heads/master
Commit: 309b34f0573d0ec593c17008e8ef4151dfc35a12
Parents: 3a818ed
Author: Benedikt Ritter <britter@apache.org>
Authored: Tue Jun 6 22:14:47 2017 +0200
Committer: Benedikt Ritter <britter@apache.org>
Committed: Tue Jun 6 22:14:47 2017 +0200

----------------------------------------------------------------------
 checkstyle.xml                                  |    3 +
 .../org/apache/commons/lang3/ObjectUtils.java   |   36 +-
 .../org/apache/commons/lang3/StringUtils.java   |    5 +-
 .../commons/lang3/builder/EqualsBuilder.java    |    9 +-
 .../commons/lang3/reflect/MemberUtils.java      |   23 +-
 .../lang3/text/translate/EntityArrays.java      |   50 +-
 .../text/translate/NumericEntityUnescaper.java  |    3 +-
 .../apache/commons/lang3/time/DateUtils.java    |    3 +-
 .../commons/lang3/time/FastDateParser.java      |    6 +-
 .../apache/commons/lang3/time/FormatCache.java  |    6 +-
 .../apache/commons/lang3/time/StopWatch.java    |   60 +-
 .../apache/commons/lang3/ArrayUtilsTest.java    | 1551 +++++++++---------
 .../apache/commons/lang3/ClassUtilsTest.java    |    3 +-
 .../commons/lang3/SerializationUtilsTest.java   |    6 +-
 .../org/apache/commons/lang3/ValidateTest.java  |   92 +-
 .../lang3/builder/EqualsBuilderTest.java        |   79 +-
 .../commons/lang3/event/EventUtilsTest.java     |  118 +-
 .../lang3/exception/ExceptionUtilsTest.java     |   46 +-
 .../commons/lang3/reflect/MethodUtilsTest.java  |  204 ++-
 .../lang3/text/ExtendedMessageFormatTest.java   |    8 +-
 .../commons/lang3/text/StrBuilderTest.java      |   12 +-
 .../commons/lang3/time/FastDateParserTest.java  |    3 +-
 .../FastDateParser_TimeZoneStrategyTest.java    |    3 +-
 .../commons/lang3/time/StopWatchTest.java       |   94 +-
 24 files changed, 1290 insertions(+), 1133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/checkstyle.xml
----------------------------------------------------------------------
diff --git a/checkstyle.xml b/checkstyle.xml
index 7d3d3a6..d912028 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -49,5 +49,8 @@ limitations under the License.
     <module name="ModifierOrder"/>
     <module name="RedundantModifier"/>
     <module name="UpperEll" />
+    <module name="LeftCurly"/>
+    <module name="NeedBraces"/>
+    <module name="RightCurly"/>
  </module>
 </module>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/ObjectUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java
index 146556b..5d86293 100644
--- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java
@@ -805,7 +805,9 @@ public class ObjectUtils {
      * @return the boolean v, unchanged
      * @since 3.2
      */
-    public static boolean CONST(final boolean v) { return v; }
+    public static boolean CONST(final boolean v) {
+        return v;
+    }
 
     /**
      * This method returns the provided value unchanged.
@@ -824,7 +826,9 @@ public class ObjectUtils {
      * @return the byte v, unchanged
      * @since 3.2
      */
-    public static byte CONST(final byte v) { return v; }
+    public static byte CONST(final byte v) {
+        return v;
+    }
 
     /**
      * This method returns the provided value unchanged.
@@ -870,7 +874,9 @@ public class ObjectUtils {
      * @return the char v, unchanged
      * @since 3.2
      */
-    public static char CONST(final char v) { return v; }
+    public static char CONST(final char v) {
+        return v;
+    }
 
     /**
      * This method returns the provided value unchanged.
@@ -889,7 +895,9 @@ public class ObjectUtils {
      * @return the short v, unchanged
      * @since 3.2
      */
-    public static short CONST(final short v) { return v; }
+    public static short CONST(final short v) {
+        return v;
+    }
 
     /**
      * This method returns the provided value unchanged.
@@ -936,7 +944,9 @@ public class ObjectUtils {
      * @return the int v, unchanged
      * @since 3.2
      */
-    public static int CONST(final int v) { return v; }
+    public static int CONST(final int v) {
+        return v;
+    }
 
     /**
      * This method returns the provided value unchanged.
@@ -955,7 +965,9 @@ public class ObjectUtils {
      * @return the long v, unchanged
      * @since 3.2
      */
-    public static long CONST(final long v) { return v; }
+    public static long CONST(final long v) {
+        return v;
+    }
 
     /**
      * This method returns the provided value unchanged.
@@ -974,7 +986,9 @@ public class ObjectUtils {
      * @return the float v, unchanged
      * @since 3.2
      */
-    public static float CONST(final float v) { return v; }
+    public static float CONST(final float v) {
+        return v;
+    }
 
     /**
      * This method returns the provided value unchanged.
@@ -993,7 +1007,9 @@ public class ObjectUtils {
      * @return the double v, unchanged
      * @since 3.2
      */
-    public static double CONST(final double v) { return v; }
+    public static double CONST(final double v) {
+        return v;
+    }
 
     /**
      * This method returns the provided value unchanged.
@@ -1013,6 +1029,8 @@ public class ObjectUtils {
      * @return the genericized Object v, unchanged (typically a String).
      * @since 3.2
      */
-    public static <T> T CONST(final T v) { return v; }
+    public static <T> T CONST(final T v) {
+        return v;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 442e285..f98433a 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -8188,9 +8188,8 @@ public class StringUtils {
             return m <= threshold ? m : -1;
         } else if (m == 0) {
             return n <= threshold ? n : -1;
-        }
-        // no need to calculate the distance if the length difference is greater than the
threshold
-        else if (Math.abs(n - m) > threshold) {
+        } else if (Math.abs(n - m) > threshold) {
+            // no need to calculate the distance if the length difference is greater than
the threshold
             return -1;
         }
 

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java b/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
index a07ea27..4e24bc5 100644
--- a/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
@@ -627,13 +627,12 @@ public class EqualsBuilder implements Builder<Boolean> {
      * @param rhs  the right hand object
      */
     private void appendArray(final Object lhs, final Object rhs) {
+        // First we compare different dimensions, for example: a boolean[][] to a boolean[]
+        // then we 'Switch' on type of array, to dispatch to the correct handler
+        // This handles multi dimensional arrays of the same depth
         if (lhs.getClass() != rhs.getClass()) {
-            // Here when we compare different dimensions, for example: a boolean[][] to a
boolean[]
             this.setEquals(false);
-        }
-        // 'Switch' on type of array, to dispatch to the correct handler
-        // This handles multi dimensional arrays of the same depth
-        else if (lhs instanceof long[]) {
+        } else if (lhs instanceof long[]) {
             append((long[]) lhs, (long[]) rhs);
         } else if (lhs instanceof int[]) {
             append((int[]) lhs, (int[]) rhs);

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
index f54e84a..86c5411 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
@@ -169,12 +169,10 @@ abstract class MemberUtils {
             if (noVarArgsPassed) {
                 // When no varargs passed, the best match is the most generic matching type,
not the most specific.
                 totalCost += getObjectTransformationCost(destClass, Object.class) + varArgsCost;
-            }
-            else if (explicitArrayForVarags) {
+            } else if (explicitArrayForVarags) {
                 final Class<?> sourceClass = srcArgs[srcArgs.length-1].getComponentType();
                 totalCost += getObjectTransformationCost(sourceClass, destClass) + varArgsCost;
-            }
-            else {
+            } else {
                 // This is typical varargs case.
                 for (int i = destArgs.length-1; i < srcArgs.length; i++) {
                     final Class<?> srcClass = srcArgs[i];
@@ -283,8 +281,13 @@ abstract class MemberUtils {
       private final Class<?>[] parameterTypes;
       private final boolean  isVarArgs;
 
-      private static Executable of(final Method method) { return new Executable(method);
}
-      private static Executable of(final Constructor<?> constructor) { return new Executable(constructor);
}
+      private static Executable of(final Method method) {
+          return new Executable(method);
+      }
+
+      private static Executable of(final Constructor<?> constructor) {
+          return new Executable(constructor);
+      }
 
       private Executable(final Method method) {
         parameterTypes = method.getParameterTypes();
@@ -296,9 +299,13 @@ abstract class MemberUtils {
         isVarArgs = constructor.isVarArgs();
       }
 
-      public Class<?>[] getParameterTypes() { return parameterTypes; }
+      public Class<?>[] getParameterTypes() {
+          return parameterTypes;
+      }
 
-      public boolean isVarArgs() { return isVarArgs; }
+      public boolean isVarArgs() {
+          return isVarArgs;
+      }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java b/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
index 276f0b1..d4357f6 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
@@ -34,7 +34,10 @@ public class EntityArrays {
      * characters to their named HTML 3.x equivalents.
      * @return the mapping table
      */
-    public static String[][] ISO8859_1_ESCAPE() { return ISO8859_1_ESCAPE.clone(); }
+    public static String[][] ISO8859_1_ESCAPE() {
+        return ISO8859_1_ESCAPE.clone();
+    }
+
     private static final String[][] ISO8859_1_ESCAPE = {
         {"\u00A0", "&nbsp;"}, // non-breaking space
         {"\u00A1", "&iexcl;"}, // inverted exclamation mark
@@ -138,7 +141,10 @@ public class EntityArrays {
      * Reverse of {@link #ISO8859_1_ESCAPE()} for unescaping purposes.
      * @return the mapping table
      */
-    public static String[][] ISO8859_1_UNESCAPE() { return ISO8859_1_UNESCAPE.clone(); }
+    public static String[][] ISO8859_1_UNESCAPE() {
+        return ISO8859_1_UNESCAPE.clone();
+    }
+
     private static final String[][] ISO8859_1_UNESCAPE = invert(ISO8859_1_ESCAPE);
 
     /**
@@ -147,7 +153,10 @@ public class EntityArrays {
      * HTML 4.0 character entities.
      * @return the mapping table
      */
-    public static String[][] HTML40_EXTENDED_ESCAPE() { return HTML40_EXTENDED_ESCAPE.clone();
}
+    public static String[][] HTML40_EXTENDED_ESCAPE() {
+        return HTML40_EXTENDED_ESCAPE.clone();
+    }
+
     private static final String[][] HTML40_EXTENDED_ESCAPE = {
         // <!-- Latin Extended-B -->
         {"\u0192", "&fnof;"}, // latin small f with hook = function= florin, U+0192 ISOtech
-->
@@ -349,7 +358,10 @@ public class EntityArrays {
      * Reverse of {@link #HTML40_EXTENDED_ESCAPE()} for unescaping purposes.
      * @return the mapping table
      */
-    public static String[][] HTML40_EXTENDED_UNESCAPE() { return HTML40_EXTENDED_UNESCAPE.clone();
}
+    public static String[][] HTML40_EXTENDED_UNESCAPE() {
+        return HTML40_EXTENDED_UNESCAPE.clone();
+    }
+
     private static final String[][] HTML40_EXTENDED_UNESCAPE = invert(HTML40_EXTENDED_ESCAPE);
 
     /**
@@ -358,7 +370,10 @@ public class EntityArrays {
      * Namely: {@code " & < >}
      * @return the mapping table
      */
-    public static String[][] BASIC_ESCAPE() { return BASIC_ESCAPE.clone(); }
+    public static String[][] BASIC_ESCAPE() {
+        return BASIC_ESCAPE.clone();
+    }
+
     private static final String[][] BASIC_ESCAPE = {
         {"\"", "&quot;"}, // " - double-quote
         {"&", "&amp;"},   // & - ampersand
@@ -370,14 +385,20 @@ public class EntityArrays {
      * Reverse of {@link #BASIC_ESCAPE()} for unescaping purposes.
      * @return the mapping table
      */
-    public static String[][] BASIC_UNESCAPE() { return BASIC_UNESCAPE.clone(); }
+    public static String[][] BASIC_UNESCAPE() {
+        return BASIC_UNESCAPE.clone();
+    }
+
     private static final String[][] BASIC_UNESCAPE = invert(BASIC_ESCAPE);
 
     /**
      * Mapping to escape the apostrophe character to its XML character entity.
      * @return the mapping table
      */
-    public static String[][] APOS_ESCAPE() { return APOS_ESCAPE.clone(); }
+    public static String[][] APOS_ESCAPE() {
+        return APOS_ESCAPE.clone();
+    }
+
     private static final String[][] APOS_ESCAPE = {
         {"'", "&apos;"}, // XML apostrophe
     };
@@ -386,7 +407,10 @@ public class EntityArrays {
      * Reverse of {@link #APOS_ESCAPE()} for unescaping purposes.
      * @return the mapping table
      */
-    public static String[][] APOS_UNESCAPE() { return APOS_UNESCAPE.clone(); }
+    public static String[][] APOS_UNESCAPE() {
+        return APOS_UNESCAPE.clone();
+    }
+
     private static final String[][] APOS_UNESCAPE = invert(APOS_ESCAPE);
 
     /**
@@ -395,7 +419,10 @@ public class EntityArrays {
      * Namely: {@code \b \n \t \f \r}
      * @return the mapping table
      */
-    public static String[][] JAVA_CTRL_CHARS_ESCAPE() { return JAVA_CTRL_CHARS_ESCAPE.clone();
}
+    public static String[][] JAVA_CTRL_CHARS_ESCAPE() {
+        return JAVA_CTRL_CHARS_ESCAPE.clone();
+    }
+
     private static final String[][] JAVA_CTRL_CHARS_ESCAPE = {
         {"\b", "\\b"},
         {"\n", "\\n"},
@@ -408,7 +435,10 @@ public class EntityArrays {
      * Reverse of {@link #JAVA_CTRL_CHARS_ESCAPE()} for unescaping purposes.
      * @return the mapping table
      */
-    public static String[][] JAVA_CTRL_CHARS_UNESCAPE() { return JAVA_CTRL_CHARS_UNESCAPE.clone();
}
+    public static String[][] JAVA_CTRL_CHARS_UNESCAPE() {
+        return JAVA_CTRL_CHARS_UNESCAPE.clone();
+    }
+
     private static final String[][] JAVA_CTRL_CHARS_UNESCAPE = invert(JAVA_CTRL_CHARS_ESCAPE);
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
index 71209ad..91e2e98 100644
--- a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
+++ b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java
@@ -100,8 +100,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
             // Note that this supports character codes without a ; on the end
             while(end < seqEnd && ( input.charAt(end) >= '0' && input.charAt(end)
<= '9' ||
                                     input.charAt(end) >= 'a' && input.charAt(end)
<= 'f' ||
-                                    input.charAt(end) >= 'A' && input.charAt(end)
<= 'F' ) )
-            {
+                                    input.charAt(end) >= 'A' && input.charAt(end)
<= 'F' ) ) {
                 end++;
             }
 

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/time/DateUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
index 7e5e4f6..9d708c3 100644
--- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
@@ -380,8 +380,7 @@ public class DateUtils {
                 if (fdp.parse(str, pos, calendar) && pos.getIndex()==str.length())
{
                     return calendar.getTime();
                 }
-            }
-            catch(final IllegalArgumentException ignore) {
+            } catch(final IllegalArgumentException ignore) {
                 // leniency is preventing calendar from being set
             }
             pos.setIndex(0);

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
index ee48179..ac60d21 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
@@ -138,11 +138,9 @@ public class FastDateParser implements DateParser, Serializable {
         if(centuryStart!=null) {
             definingCalendar.setTime(centuryStart);
             centuryStartYear= definingCalendar.get(Calendar.YEAR);
-        }
-        else if(locale.equals(JAPANESE_IMPERIAL)) {
+        } else if(locale.equals(JAPANESE_IMPERIAL)) {
             centuryStartYear= 0;
-        }
-        else {
+        } else {
             // from 80 years ago to 20 years from now
             definingCalendar.setTime(new Date());
             centuryStartYear= definingCalendar.get(Calendar.YEAR)-80;

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/time/FormatCache.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/time/FormatCache.java b/src/main/java/org/apache/commons/lang3/time/FormatCache.java
index 23c08e6..1cb711a 100644
--- a/src/main/java/org/apache/commons/lang3/time/FormatCache.java
+++ b/src/main/java/org/apache/commons/lang3/time/FormatCache.java
@@ -196,11 +196,9 @@ abstract class FormatCache<F extends Format> {
                 DateFormat formatter;
                 if (dateStyle == null) {
                     formatter = DateFormat.getTimeInstance(timeStyle.intValue(), locale);
-                }
-                else if (timeStyle == null) {
+                } else if (timeStyle == null) {
                     formatter = DateFormat.getDateInstance(dateStyle.intValue(), locale);
-                }
-                else {
+                } else {
                     formatter = DateFormat.getDateTimeInstance(dateStyle.intValue(), timeStyle.intValue(),
locale);
                 }
                 pattern = ((SimpleDateFormat)formatter).toPattern();

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/309b34f0/src/main/java/org/apache/commons/lang3/time/StopWatch.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/time/StopWatch.java b/src/main/java/org/apache/commons/lang3/time/StopWatch.java
index 573fa86..feb2388 100644
--- a/src/main/java/org/apache/commons/lang3/time/StopWatch.java
+++ b/src/main/java/org/apache/commons/lang3/time/StopWatch.java
@@ -80,24 +80,60 @@ public class StopWatch {
     private enum State {
 
         UNSTARTED {
-            @Override boolean isStarted() { return false; }
-            @Override boolean isStopped() { return true;  }
-            @Override boolean isSuspended() { return false; }
+            @Override
+            boolean isStarted() {
+                return false;
+            }
+            @Override
+            boolean isStopped() {
+                return true;
+            }
+            @Override
+            boolean isSuspended() {
+                return false;
+            }
         },
         RUNNING {
-            @Override boolean isStarted() { return true; }
-            @Override boolean isStopped() { return false; }
-            @Override boolean isSuspended() { return false; }
+            @Override
+            boolean isStarted() {
+                return true;
+            }
+            @Override
+            boolean isStopped() {
+                return false;
+            }
+            @Override
+            boolean isSuspended() {
+                return false;
+            }
         },
         STOPPED {
-            @Override boolean isStarted() { return false; }
-            @Override boolean isStopped() { return true; }
-            @Override boolean isSuspended() { return false; }
+            @Override
+            boolean isStarted() {
+                return false;
+            }
+            @Override
+            boolean isStopped() {
+                return true;
+            }
+            @Override
+            boolean isSuspended() {
+                return false;
+            }
         },
         SUSPENDED {
-            @Override boolean isStarted() { return true; }
-            @Override boolean isStopped() { return false; }
-            @Override  boolean isSuspended() { return true; }
+            @Override
+            boolean isStarted() {
+                return true;
+            }
+            @Override
+            boolean isStopped() {
+                return false;
+            }
+            @Override
+            boolean isSuspended() {
+                return true;
+            }
         };
 
         /**


Mime
View raw message