1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package ch.qos.logback.core.util;
16
17 import ch.qos.logback.core.CoreConstants;
18
19
20
21
22 public class StringUtil {
23
24 public static String nullStringToEmpty(String input) {
25 if (input != null)
26 return input;
27 else
28 return CoreConstants.EMPTY_STRING;
29 }
30
31
32
33
34
35
36
37 public static boolean isNullOrEmpty(String str) {
38 return ((str == null) || str.isEmpty());
39 }
40
41
42
43
44
45
46
47 public static boolean notNullNorEmpty(String str) {
48 return !isNullOrEmpty(str);
49 }
50
51 public static String capitalizeFirstLetter(String name) {
52 if (isNullOrEmpty(name))
53 return name;
54
55 if (name.length() == 1) {
56 return name.toUpperCase();
57 } else
58 return name.substring(0, 1).toUpperCase() + name.substring(1);
59 }
60
61 public static String lowercaseFirstLetter(String name) {
62 if (isNullOrEmpty(name))
63 return name;
64
65 if (name.length() == 1) {
66 return name.toLowerCase();
67 } else
68 return name.substring(0, 1).toLowerCase() + name.substring(1);
69 }
70
71 }