You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2019/11/06 15:40:11 UTC
[empire-db] branch master updated: EMPIREDB-282 More cleanup
This is an automated email from the ASF dual-hosted git repository.
doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git
The following commit(s) were added to refs/heads/master by this push:
new d2b4ec2 EMPIREDB-282 More cleanup
d2b4ec2 is described below
commit d2b4ec25b7ea42525a8cb7720b768d0484be397e
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Wed Nov 6 16:40:06 2019 +0100
EMPIREDB-282
More cleanup
---
.../org/apache/empire/commons/StringUtils.java | 28 ++++++++--------------
.../org/apache/empire/commons/OptionsTest.java | 2 +-
2 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java b/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
index 67bd2d7..b13345b 100644
--- a/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
@@ -112,7 +112,7 @@ public class StringUtils
*/
public static String coalesce(String preferred, String alternative)
{
- return isValid(preferred) ? preferred : alternative;
+ return isNotEmpty(preferred) ? preferred : alternative;
}
/**
@@ -192,22 +192,14 @@ public class StringUtils
*/
public static boolean isEmpty(String s)
{
- return s == null || s.trim().length() == 0;
- }
-
- /**
- * Checks if a string is not null or empty
- *
- * @param s the string to validate
- *
- * @return true if valid
- *
- * @deprecated this has been renamed to isNotEmpty
- */
- @Deprecated
- public static boolean isValid(String s)
- {
- return s != null && s.trim().length() > 0;
+ if (s!=null)
+ { // find non-space character
+ for (int i=0; i<s.length(); i++)
+ if (s.charAt(i)>' ')
+ return false;
+ }
+ // empty
+ return true;
}
/**
@@ -219,7 +211,7 @@ public class StringUtils
*/
public static boolean isNotEmpty(String s)
{
- return s != null && s.trim().length() > 0;
+ return !isEmpty(s);
}
/**
diff --git a/empire-db/src/test/java/org/apache/empire/commons/OptionsTest.java b/empire-db/src/test/java/org/apache/empire/commons/OptionsTest.java
index 73e738b..faf97f8 100644
--- a/empire-db/src/test/java/org/apache/empire/commons/OptionsTest.java
+++ b/empire-db/src/test/java/org/apache/empire/commons/OptionsTest.java
@@ -245,7 +245,7 @@ public class OptionsTest
options.add(Integer.valueOf(1), "text", true);
assertEquals(Integer.valueOf(1), options.getValueAt(0));
options.add(Integer.valueOf(1), "text", true);
- assertEquals(Integer.valueOf(1), options.getValueAt(1));
+ assertEquals(Integer.valueOf(1), options.getValueAt(0));
options = new Options();
options.add(Integer.valueOf(1), "text", false);