Skip to content

Commit 2a8c3a2

Browse files
authored
Merge pull request apolloconfig#753 from Acceml/huming
clean code for isBlank
2 parents 2b49ae5 + bfba1d3 commit 2a8c3a2

File tree

1 file changed

+3
-13
lines changed
  • apollo-core/src/main/java/com/ctrip/framework/foundation/internals

1 file changed

+3
-13
lines changed

apollo-core/src/main/java/com/ctrip/framework/foundation/internals/Utils.java

100644100755
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
package com.ctrip.framework.foundation.internals;
22

3+
import com.google.common.base.Strings;
4+
35
public class Utils {
46
public static boolean isBlank(String str) {
5-
if (str == null || str.length() == 0) {
6-
return true;
7-
}
8-
9-
int length = str.length();
10-
for (int i = 0; i < length; i++) {
11-
char ch = str.charAt(i);
12-
13-
if (!Character.isWhitespace(ch)) {
14-
return false;
15-
}
16-
}
17-
return true;
7+
return Strings.nullToEmpty(str).trim().isEmpty();
188
}
199

2010
public static boolean isOSWindows() {

0 commit comments

Comments
 (0)