public class StringKit extends Object
构造器和说明 |
---|
StringKit() |
限定符和类型 | 方法和说明 |
---|---|
static String |
alignLeft(Object o,
int width,
char c)
Fill a certain number of special characters on the right side of the string
|
static String |
alignRight(Object o,
int width,
char c)
Fill a certain number of special characters on the left side of the string
|
static String |
dup(char c,
int num)
Copy characters
|
static boolean |
equals(String str1,
String str2) |
static String |
fileExt(String fname) |
static boolean |
isAnyBlank(String... values)
There is at least one null in the array of strings
|
static boolean |
isBlank(String str)
Determine whether a string is blank
|
static void |
isBlankThen(String str,
Consumer<String> consumer)
Execute consumer when the string is empty
|
static boolean |
isEmpty(String str) |
static boolean |
isNotBlank(String... str)
Determine whether a list of string is not blank
|
static void |
isNotBlankThen(String str,
Consumer<String> consumer)
Execute consumer when the string is not empty
|
static boolean |
isNotEmpty(String str) |
static boolean |
isNumber(String value)
determines whether the string is a numeric format
|
static String |
mimeType(String fileName) |
static <T> T |
noNullElseGet(Supplier<T> s1,
Supplier<T> s2)
we can replace
if(doMethod1()!
|
static <R> void |
notBankAccept(String str,
Function<String,R> function,
Consumer<R> consumer)
we can replace
`
if(StringUtils.isNotBlank(str)) {
Integer i = Integer.parseInt (str)
demo.setAge(i)
}
`
with
`
notBankAccept ("2", Integer::parseInt, route::setSort)
`
|
static void |
notBankThen(String str,
Runnable action)
Execute action when String is not empty
|
static String |
padLeft(String s,
int n) |
static String |
padRight(String s,
int n) |
static String |
rand(int size)
Generate a number of numeric strings randomly
|
static int |
rand(int min,
int max)
Randomly generate a number in the min and Max range
|
static String |
toCamelCase(String s) |
static String |
toCapitalizeCamelCase(String s) |
static String |
toUnderlineName(String s) |
public static int rand(int min, int max)
min
- min valuemax
- max valuepublic static String rand(int size)
size
- string countpublic static boolean isNotBlank(String... str)
str
- a list of string valuepublic static void isNotBlankThen(String str, Consumer<String> consumer)
str
- string valueconsumer
- consumerpublic static void isBlankThen(String str, Consumer<String> consumer)
str
- string valueconsumer
- consumerpublic static <R> void notBankAccept(String str, Function<String,R> function, Consumer<R> consumer)
str
- string valueconsumer
- consumerfunction
- formatpublic static void notBankThen(String str, Runnable action)
str
- String valueaction
- actionpublic static <T> T noNullElseGet(@NonNull Supplier<T> s1, @NonNull Supplier<T> s2)
s1
- Suppliers2
- Supplierpublic static boolean isBlank(String str)
str
- string valuepublic static boolean isEmpty(String str)
public static boolean isNotEmpty(String str)
public static boolean isAnyBlank(String... values)
values
- string arraypublic static boolean isNumber(String value)
value
- string valuepublic static String alignLeft(Object o, int width, char c)
o
- objects that can be to Stringwidth
- number of charactersc
- characterspublic static String alignRight(Object o, int width, char c)
o
- objects that can be to Stringwidth
- number of charactersc
- characterspublic static String dup(char c, int num)
c
- charactersnum
- character numberCopyright © 2018. All rights reserved.