You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/05/05 11:51:28 UTC
[12/14] [text] moved validations on start of method
moved validations on start of method
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/9615df73
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/9615df73
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/9615df73
Branch: refs/heads/master
Commit: 9615df734b6ee4633e45eb3d737a9f5f2dc07654
Parents: 83b3662
Author: Amey Jadiye <am...@gmail.com>
Authored: Fri May 5 01:22:14 2017 +0530
Committer: Amey Jadiye <am...@gmail.com>
Committed: Fri May 5 01:22:14 2017 +0530
----------------------------------------------------------------------
src/main/java/org/apache/commons/text/WordUtils.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/9615df73/src/main/java/org/apache/commons/text/WordUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/WordUtils.java b/src/main/java/org/apache/commons/text/WordUtils.java
index 3409d7c..20920d6 100644
--- a/src/main/java/org/apache/commons/text/WordUtils.java
+++ b/src/main/java/org/apache/commons/text/WordUtils.java
@@ -782,11 +782,6 @@ public class WordUtils {
*/
public static String abbreviate(String str, int lower, int upper, String appendToEnd) {
-
- if (StringUtils.isEmpty(str)) {
- return str;
- }
-
// throw IllegalArgumentException if upper limit is less than -1 which voids contact.
if (upper < -1) {
throw new IllegalArgumentException("upper value cannot be less than -1");
@@ -797,6 +792,10 @@ public class WordUtils {
throw new IllegalArgumentException("upper value is less than lower value");
}
+ if (StringUtils.isEmpty(str)) {
+ return str;
+ }
+
// if the lower value is greater than the length of the string,
// set to the length of the string
if (lower > str.length()) {