You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/10/09 14:46:15 UTC

[text] Remove useless parens.

Repository: commons-text
Updated Branches:
  refs/heads/master 84cc3c2b2 -> add84546d


Remove useless parens.

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

Branch: refs/heads/master
Commit: add84546d7dbde6ef892b1dfcbabf9c8291913db
Parents: 84cc3c2
Author: Gary Gregory <gg...@rocketsoftware.com>
Authored: Tue Oct 9 08:46:12 2018 -0600
Committer: Gary Gregory <gg...@rocketsoftware.com>
Committed: Tue Oct 9 08:46:12 2018 -0600

----------------------------------------------------------------------
 .../org/apache/commons/text/StrBuilder.java     | 46 ++++++++++----------
 .../apache/commons/text/TextStringBuilder.java  | 46 ++++++++++----------
 2 files changed, 46 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/add84546/src/main/java/org/apache/commons/text/StrBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/StrBuilder.java b/src/main/java/org/apache/commons/text/StrBuilder.java
index 9df3061..dd6ae53 100644
--- a/src/main/java/org/apache/commons/text/StrBuilder.java
+++ b/src/main/java/org/apache/commons/text/StrBuilder.java
@@ -590,7 +590,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         if (startIndex < 0 || startIndex > str.length()) {
             throw new StringIndexOutOfBoundsException("startIndex must be valid");
         }
-        if (length < 0 || (startIndex + length) > str.length()) {
+        if (length < 0 || startIndex + length > str.length()) {
             throw new StringIndexOutOfBoundsException("length must be valid");
         }
         if (length > 0) {
@@ -655,7 +655,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
             if (startIndex < 0 || startIndex > totalLength) {
                 throw new StringIndexOutOfBoundsException("startIndex must be valid");
             }
-            if (length < 0 || (startIndex + length) > totalLength) {
+            if (length < 0 || startIndex + length > totalLength) {
                 throw new StringIndexOutOfBoundsException("length must be valid");
             }
             final int len = length();
@@ -705,7 +705,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         if (startIndex < 0 || startIndex > str.length()) {
             throw new StringIndexOutOfBoundsException("startIndex must be valid");
         }
-        if (length < 0 || (startIndex + length) > str.length()) {
+        if (length < 0 || startIndex + length > str.length()) {
             throw new StringIndexOutOfBoundsException("length must be valid");
         }
         if (length > 0) {
@@ -754,7 +754,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         if (startIndex < 0 || startIndex > str.length()) {
             throw new StringIndexOutOfBoundsException("startIndex must be valid");
         }
-        if (length < 0 || (startIndex + length) > str.length()) {
+        if (length < 0 || startIndex + length > str.length()) {
             throw new StringIndexOutOfBoundsException("length must be valid");
         }
         if (length > 0) {
@@ -803,7 +803,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         if (startIndex < 0 || startIndex > str.length()) {
             throw new StringIndexOutOfBoundsException("startIndex must be valid");
         }
-        if (length < 0 || (startIndex + length) > str.length()) {
+        if (length < 0 || startIndex + length > str.length()) {
             throw new StringIndexOutOfBoundsException("length must be valid");
         }
         if (length > 0) {
@@ -852,7 +852,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         if (startIndex < 0 || startIndex > chars.length) {
             throw new StringIndexOutOfBoundsException("Invalid startIndex: " + length);
         }
-        if (length < 0 || (startIndex + length) > chars.length) {
+        if (length < 0 || startIndex + length > chars.length) {
             throw new StringIndexOutOfBoundsException("Invalid length: " + length);
         }
         if (length > 0) {
@@ -1464,7 +1464,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
     public StrBuilder appendFixedWidthPadLeft(final Object obj, final int width, final char padChar) {
         if (width > 0) {
             ensureCapacity(size + width);
-            String str = (obj == null ? getNullText() : obj.toString());
+            String str = obj == null ? getNullText() : obj.toString();
             if (str == null) {
                 str = "";
             }
@@ -1511,7 +1511,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
     public StrBuilder appendFixedWidthPadRight(final Object obj, final int width, final char padChar) {
         if (width > 0) {
             ensureCapacity(size + width);
-            String str = (obj == null ? getNullText() : obj.toString());
+            String str = obj == null ? getNullText() : obj.toString();
             if (str == null) {
                 str = "";
             }
@@ -1819,7 +1819,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return this, to enable chaining
      */
     public StrBuilder deleteAll(final String str) {
-        final int len = (str == null ? 0 : str.length());
+        final int len = str == null ? 0 : str.length();
         if (len > 0) {
             int index = indexOf(str, 0);
             while (index >= 0) {
@@ -1837,7 +1837,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return this, to enable chaining
      */
     public StrBuilder deleteFirst(final String str) {
-        final int len = (str == null ? 0 : str.length());
+        final int len = str == null ? 0 : str.length();
         if (len > 0) {
             final int index = indexOf(str, 0);
             if (index >= 0) {
@@ -1916,7 +1916,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      */
     public StrBuilder replace(final int startIndex, int endIndex, final String replaceStr) {
         endIndex = validateRange(startIndex, endIndex);
-        final int insertLen = (replaceStr == null ? 0 : replaceStr.length());
+        final int insertLen = replaceStr == null ? 0 : replaceStr.length();
         replaceImpl(startIndex, endIndex, endIndex - startIndex, replaceStr, insertLen);
         return this;
     }
@@ -1970,9 +1970,9 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return this, to enable chaining
      */
     public StrBuilder replaceAll(final String searchStr, final String replaceStr) {
-        final int searchLen = (searchStr == null ? 0 : searchStr.length());
+        final int searchLen = searchStr == null ? 0 : searchStr.length();
         if (searchLen > 0) {
-            final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+            final int replaceLen = replaceStr == null ? 0 : replaceStr.length();
             int index = indexOf(searchStr, 0);
             while (index >= 0) {
                 replaceImpl(index, index + searchLen, searchLen, replaceStr, replaceLen);
@@ -1990,11 +1990,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return this, to enable chaining
      */
     public StrBuilder replaceFirst(final String searchStr, final String replaceStr) {
-        final int searchLen = (searchStr == null ? 0 : searchStr.length());
+        final int searchLen = searchStr == null ? 0 : searchStr.length();
         if (searchLen > 0) {
             final int index = indexOf(searchStr, 0);
             if (index >= 0) {
-                final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+                final int replaceLen = replaceStr == null ? 0 : replaceStr.length();
                 replaceImpl(index, index + searchLen, searchLen, replaceStr, replaceLen);
             }
         }
@@ -2077,7 +2077,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         if (matcher == null || size == 0) {
             return this;
         }
-        final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+        final int replaceLen = replaceStr == null ? 0 : replaceStr.length();
         for (int i = from; i < to && replaceCount != 0; i++) {
             final char[] buf = buffer;
             final int removeLen = matcher.isMatch(buf, i, from, to);
@@ -2380,7 +2380,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return the first index of the character, or -1 if not found
      */
     public int indexOf(final char ch, int startIndex) {
-        startIndex = (startIndex < 0 ? 0 : startIndex);
+        startIndex = startIndex < 0 ? 0 : startIndex;
         if (startIndex >= size) {
             return -1;
         }
@@ -2416,7 +2416,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return the first index of the string, or -1 if not found
      */
     public int indexOf(final String str, int startIndex) {
-        startIndex = (startIndex < 0 ? 0 : startIndex);
+        startIndex = startIndex < 0 ? 0 : startIndex;
         if (str == null || startIndex >= size) {
             return -1;
         }
@@ -2471,7 +2471,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return the first index matched, or -1 if not found
      */
     public int indexOf(final StrMatcher matcher, int startIndex) {
-        startIndex = (startIndex < 0 ? 0 : startIndex);
+        startIndex = startIndex < 0 ? 0 : startIndex;
         if (matcher == null || startIndex >= size) {
             return -1;
         }
@@ -2504,7 +2504,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return the last index of the character, or -1 if not found
      */
     public int lastIndexOf(final char ch, int startIndex) {
-        startIndex = (startIndex >= size ? size - 1 : startIndex);
+        startIndex = startIndex >= size ? size - 1 : startIndex;
         if (startIndex < 0) {
             return -1;
         }
@@ -2539,7 +2539,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return the last index of the string, or -1 if not found
      */
     public int lastIndexOf(final String str, int startIndex) {
-        startIndex = (startIndex >= size ? size - 1 : startIndex);
+        startIndex = startIndex >= size ? size - 1 : startIndex;
         if (str == null || startIndex < 0) {
             return -1;
         }
@@ -2592,7 +2592,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
      * @return the last index matched, or -1 if not found
      */
     public int lastIndexOf(final StrMatcher matcher, int startIndex) {
-        startIndex = (startIndex >= size ? size - 1 : startIndex);
+        startIndex = startIndex >= size ? size - 1 : startIndex;
         if (matcher == null || startIndex < 0) {
             return -1;
         }
@@ -2948,7 +2948,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         @Override
         public int read(final char[] b, final int off, int len) {
             if (off < 0 || len < 0 || off > b.length
-                    || (off + len) > b.length || (off + len) < 0) {
+                    || off + len > b.length || off + len < 0) {
                 throw new IndexOutOfBoundsException();
             }
             if (len == 0) {

http://git-wip-us.apache.org/repos/asf/commons-text/blob/add84546/src/main/java/org/apache/commons/text/TextStringBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index 8943d03..6c151d6 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -622,7 +622,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
         if (startIndex < 0 || startIndex > str.length()) {
             throw new StringIndexOutOfBoundsException("startIndex must be valid");
         }
-        if (length < 0 || (startIndex + length) > str.length()) {
+        if (length < 0 || startIndex + length > str.length()) {
             throw new StringIndexOutOfBoundsException("length must be valid");
         }
         if (length > 0) {
@@ -691,7 +691,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
             if (startIndex < 0 || startIndex > totalLength) {
                 throw new StringIndexOutOfBoundsException("startIndex must be valid");
             }
-            if (length < 0 || (startIndex + length) > totalLength) {
+            if (length < 0 || startIndex + length > totalLength) {
                 throw new StringIndexOutOfBoundsException("length must be valid");
             }
             final int len = length();
@@ -743,7 +743,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
         if (startIndex < 0 || startIndex > str.length()) {
             throw new StringIndexOutOfBoundsException("startIndex must be valid");
         }
-        if (length < 0 || (startIndex + length) > str.length()) {
+        if (length < 0 || startIndex + length > str.length()) {
             throw new StringIndexOutOfBoundsException("length must be valid");
         }
         if (length > 0) {
@@ -794,7 +794,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
         if (startIndex < 0 || startIndex > str.length()) {
             throw new StringIndexOutOfBoundsException("startIndex must be valid");
         }
-        if (length < 0 || (startIndex + length) > str.length()) {
+        if (length < 0 || startIndex + length > str.length()) {
             throw new StringIndexOutOfBoundsException("length must be valid");
         }
         if (length > 0) {
@@ -845,7 +845,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
         if (startIndex < 0 || startIndex > str.length()) {
             throw new StringIndexOutOfBoundsException("startIndex must be valid");
         }
-        if (length < 0 || (startIndex + length) > str.length()) {
+        if (length < 0 || startIndex + length > str.length()) {
             throw new StringIndexOutOfBoundsException("length must be valid");
         }
         if (length > 0) {
@@ -896,7 +896,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
         if (startIndex < 0 || startIndex > chars.length) {
             throw new StringIndexOutOfBoundsException("Invalid startIndex: " + length);
         }
-        if (length < 0 || (startIndex + length) > chars.length) {
+        if (length < 0 || startIndex + length > chars.length) {
             throw new StringIndexOutOfBoundsException("Invalid length: " + length);
         }
         if (length > 0) {
@@ -1552,7 +1552,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
     public TextStringBuilder appendFixedWidthPadLeft(final Object obj, final int width, final char padChar) {
         if (width > 0) {
             ensureCapacity(size + width);
-            String str = (obj == null ? getNullText() : obj.toString());
+            String str = obj == null ? getNullText() : obj.toString();
             if (str == null) {
                 str = "";
             }
@@ -1603,7 +1603,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
     public TextStringBuilder appendFixedWidthPadRight(final Object obj, final int width, final char padChar) {
         if (width > 0) {
             ensureCapacity(size + width);
-            String str = (obj == null ? getNullText() : obj.toString());
+            String str = obj == null ? getNullText() : obj.toString();
             if (str == null) {
                 str = "";
             }
@@ -1951,7 +1951,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return this, to enable chaining
      */
     public TextStringBuilder deleteAll(final String str) {
-        final int len = (str == null ? 0 : str.length());
+        final int len = str == null ? 0 : str.length();
         if (len > 0) {
             int index = indexOf(str, 0);
             while (index >= 0) {
@@ -1970,7 +1970,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return this, to enable chaining
      */
     public TextStringBuilder deleteFirst(final String str) {
-        final int len = (str == null ? 0 : str.length());
+        final int len = str == null ? 0 : str.length();
         if (len > 0) {
             final int index = indexOf(str, 0);
             if (index >= 0) {
@@ -2055,7 +2055,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      */
     public TextStringBuilder replace(final int startIndex, int endIndex, final String replaceStr) {
         endIndex = validateRange(startIndex, endIndex);
-        final int insertLen = (replaceStr == null ? 0 : replaceStr.length());
+        final int insertLen = replaceStr == null ? 0 : replaceStr.length();
         replaceImpl(startIndex, endIndex, endIndex - startIndex, replaceStr, insertLen);
         return this;
     }
@@ -2113,9 +2113,9 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return this, to enable chaining
      */
     public TextStringBuilder replaceAll(final String searchStr, final String replaceStr) {
-        final int searchLen = (searchStr == null ? 0 : searchStr.length());
+        final int searchLen = searchStr == null ? 0 : searchStr.length();
         if (searchLen > 0) {
-            final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+            final int replaceLen = replaceStr == null ? 0 : replaceStr.length();
             int index = indexOf(searchStr, 0);
             while (index >= 0) {
                 replaceImpl(index, index + searchLen, searchLen, replaceStr, replaceLen);
@@ -2135,11 +2135,11 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return this, to enable chaining
      */
     public TextStringBuilder replaceFirst(final String searchStr, final String replaceStr) {
-        final int searchLen = (searchStr == null ? 0 : searchStr.length());
+        final int searchLen = searchStr == null ? 0 : searchStr.length();
         if (searchLen > 0) {
             final int index = indexOf(searchStr, 0);
             if (index >= 0) {
-                final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+                final int replaceLen = replaceStr == null ? 0 : replaceStr.length();
                 replaceImpl(index, index + searchLen, searchLen, replaceStr, replaceLen);
             }
         }
@@ -2231,7 +2231,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
         if (matcher == null || size == 0) {
             return this;
         }
-        final int replaceLen = (replaceStr == null ? 0 : replaceStr.length());
+        final int replaceLen = replaceStr == null ? 0 : replaceStr.length();
         for (int i = from; i < to && replaceCount != 0; i++) {
             final char[] buf = buffer;
             final int removeLen = matcher.isMatch(buf, i, from, to);
@@ -2536,7 +2536,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return the first index of the character, or -1 if not found
      */
     public int indexOf(final char ch, int startIndex) {
-        startIndex = (startIndex < 0 ? 0 : startIndex);
+        startIndex = startIndex < 0 ? 0 : startIndex;
         if (startIndex >= size) {
             return -1;
         }
@@ -2575,7 +2575,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return the first index of the string, or -1 if not found
      */
     public int indexOf(final String str, int startIndex) {
-        startIndex = (startIndex < 0 ? 0 : startIndex);
+        startIndex = startIndex < 0 ? 0 : startIndex;
         if (str == null || startIndex >= size) {
             return -1;
         }
@@ -2629,7 +2629,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return the first index matched, or -1 if not found
      */
     public int indexOf(final StringMatcher matcher, int startIndex) {
-        startIndex = (startIndex < 0 ? 0 : startIndex);
+        startIndex = startIndex < 0 ? 0 : startIndex;
         if (matcher == null || startIndex >= size) {
             return -1;
         }
@@ -2665,7 +2665,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return the last index of the character, or -1 if not found
      */
     public int lastIndexOf(final char ch, int startIndex) {
-        startIndex = (startIndex >= size ? size - 1 : startIndex);
+        startIndex = startIndex >= size ? size - 1 : startIndex;
         if (startIndex < 0) {
             return -1;
         }
@@ -2703,7 +2703,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return the last index of the string, or -1 if not found
      */
     public int lastIndexOf(final String str, int startIndex) {
-        startIndex = (startIndex >= size ? size - 1 : startIndex);
+        startIndex = startIndex >= size ? size - 1 : startIndex;
         if (str == null || startIndex < 0) {
             return -1;
         }
@@ -2755,7 +2755,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return the last index matched, or -1 if not found
      */
     public int lastIndexOf(final StringMatcher matcher, int startIndex) {
-        startIndex = (startIndex >= size ? size - 1 : startIndex);
+        startIndex = startIndex >= size ? size - 1 : startIndex;
         if (matcher == null || startIndex < 0) {
             return -1;
         }
@@ -3102,7 +3102,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
         /** {@inheritDoc} */
         @Override
         public int read(final char[] b, final int off, int len) {
-            if (off < 0 || len < 0 || off > b.length || (off + len) > b.length || (off + len) < 0) {
+            if (off < 0 || len < 0 || off > b.length || off + len > b.length || off + len < 0) {
                 throw new IndexOutOfBoundsException();
             }
             if (len == 0) {