public class $ extends Object
| Constructor and Description |
|---|
$() |
| Modifier and Type | Method and Description |
|---|---|
static String |
cleanIdentifier(String param)
获取标识符,用于参数清理
|
static String |
cleanText(String txt)
清理字符串,清理出某些不可见字符和一些sql特殊字符
|
static String[] |
concat(String[] one,
String[] other)
Concatenates 2 arrays
|
static <T> T[] |
concat(T[] one,
T[] other,
Class<T> clazz)
Concatenates 2 arrays
|
static boolean |
contains(Enumeration<?> enumeration,
Object element)
判断枚举是否包含该元素
|
static boolean |
contains(Iterator<?> iterator,
Object element)
判断迭代器中是否包含元素
|
static <T> boolean |
contains(T[] array,
T element)
判断数组中是否包含元素
|
static Object |
defaultIfNull(Object object,
Object defaultValue)
如果对象为null,返回默认值
|
static boolean |
equals(Object o1,
Object o2)
对象 eq
|
static boolean |
equalsSafe(Object o1,
Object o2)
安全的 equals
|
static String |
firstCharToLower(String str)
首字母变小写
|
static String |
firstCharToUpper(String str)
首字母变大写
|
static String |
format(String message,
Map<String,Object> params)
将字符串中特定模式的字符转换成map中对应的值
|
static String |
format(String message,
Object... arguments)
同 log 格式的 format 规则
|
static int |
hashCode(Object obj)
返回对象的 hashCode
|
static boolean |
isAnyBlank(CharSequence... css)
判断是否有任意一个 空字符串
|
static boolean |
isArray(Object obj)
判断对象是数组
|
static boolean |
isBlank(CharSequence cs)
判断是否为空字符串
$.isBlank(null) = true
$.isBlank("") = true
$.isBlank(" ") = true
$.isBlank("12345") = false
$.isBlank(" 12345 ") = false |
static boolean |
isEmpty(Object obj)
判断空对象 object、map、list、set、字符串、数组
|
static boolean |
isEmpty(Object[] array)
判断数组为空
|
static boolean |
isFalse(Boolean object)
判断对象为false
|
static boolean |
isNotBlank(CharSequence cs)
判断不为空字符串
|
static boolean |
isNotEmpty(Object obj)
对象不为空 object、map、list、set、字符串、数组
|
static boolean |
isNotEmpty(Object[] array)
判断数组不为空
|
static boolean |
isNotEqual(Object o1,
Object o2)
比较两个对象是否不相等
|
static boolean |
isNotNull(Object obj)
判断对象是否 not null
|
static boolean |
isNull(Object obj)
判断对象是否为null
|
static boolean |
isTrue(Boolean object)
判断对象为true
|
static <E> List<E> |
ofImmutableList(E... es)
不可变 List
|
static <E> Set<E> |
ofImmutableSet(E... es)
不可变 Set
|
static <T> T |
requireNotNull(T obj)
断言,必须不能为 null
|
static <T> T |
requireNotNull(T obj,
String message)
断言,必须不能为 null
|
static <T> T |
requireNotNull(T obj,
Supplier<String> messageSupplier)
断言,必须不能为 null
|
public static <T> T requireNotNull(T obj)
T - the type of the referenceobj - the object reference to check for nullityobj if not nullNullPointerException - if obj is nullpublic static <T> T requireNotNull(T obj,
String message)
T - the type of the referenceobj - the object reference to check for nullitymessage - detail message to be used in the event that a NullPointerException is thrownobj if not nullNullPointerException - if obj is nullpublic static <T> T requireNotNull(T obj,
Supplier<String> messageSupplier)
T - the type of the referenceobj - the object reference to check for nullitymessageSupplier - supplier of the detail message to be
used in the event that a NullPointerException is thrownobj if not nullNullPointerException - if obj is nullpublic static boolean isTrue(Boolean object)
object - 对象public static boolean isFalse(Boolean object)
object - 对象public static boolean isNull(Object obj)
This method exists to be used as a
Predicate, context($::isNull)
obj - a reference to be checked against nulltrue if the provided reference is null otherwise
falsePredicatepublic static boolean isNotNull(Object obj)
This method exists to be used as a
Predicate, context($::notNull)
obj - a reference to be checked against nulltrue if the provided reference is non-null
otherwise falsePredicatepublic static String firstCharToLower(String str)
str - 字符串public static String firstCharToUpper(String str)
str - 字符串public static boolean isBlank(CharSequence cs)
$.isBlank(null) = true
$.isBlank("") = true
$.isBlank(" ") = true
$.isBlank("12345") = false
$.isBlank(" 12345 ") = false
cs - the CharSequence to check (may be null)true if the CharSequence is not null,
its length is greater than 0, and it does not contain whitespace onlyCharacter.isWhitespace(char)public static boolean isNotBlank(CharSequence cs)
$.isNotBlank(null) = false
$.isNotBlank("") = false
$.isNotBlank(" ") = false
$.isNotBlank("bob") = true
$.isNotBlank(" bob ") = true
cs - the CharSequence to check, may be nulltrue if the CharSequence is
not empty and not null and not whitespaceCharacter.isWhitespace(char)public static boolean isAnyBlank(CharSequence... css)
css - CharSequencepublic static boolean isArray(Object obj)
obj - the object to checkpublic static boolean isEmpty(Object obj)
obj - the object to checkpublic static boolean isNotEmpty(Object obj)
obj - the object to checkpublic static boolean isEmpty(Object[] array)
array - the array to checkpublic static boolean isNotEmpty(Object[] array)
array - 数组public static String format(String message, Map<String,Object> params)
use: format("my name is ${name}, and i like ${like}!", {"name":"L.cm", "like": "Java"})
message - 需要转换的字符串params - 转换所需的键值对集合public static String format(String message, Object... arguments)
use: format("my name is {}, and i like {}!", "L.cm", "Java")
message - 需要转换的字符串arguments - 需要替换的变量public static String cleanText(String txt)
txt - 文本public static String cleanIdentifier(String param)
param - 参数public static boolean equalsSafe(Object o1, Object o2)
o1 - first Object to compareo2 - second Object to compareObject.equals(Object),
Arrays.equals(long[], long[])public static boolean equals(Object o1, Object o2)
o1 - Objecto2 - Objectpublic static boolean isNotEqual(Object o1, Object o2)
o1 - 对象1o2 - 对象2public static int hashCode(Object obj)
obj - Objectpublic static Object defaultIfNull(Object object, Object defaultValue)
object - ObjectdefaultValue - 默认值public static <T> boolean contains(T[] array,
T element)
T - The generic tagarray - the Array to checkelement - the element to look fortrue if found, false elsepublic static boolean contains(Iterator<?> iterator, Object element)
iterator - the Iterator to checkelement - the element to look fortrue if found, false otherwisepublic static boolean contains(Enumeration<?> enumeration, Object element)
enumeration - the Enumeration to checkelement - the element to look fortrue if found, false otherwisepublic static String[] concat(String[] one, String[] other)
one - 数组1other - 数组2public static <T> T[] concat(T[] one,
T[] other,
Class<T> clazz)
T - 对象one - 数组1other - 数组2clazz - 数组类public static <E> Set<E> ofImmutableSet(E... es)
E - 泛型es - 对象public static <E> List<E> ofImmutableList(E... es)
E - 泛型es - 对象Copyright © 2020. All rights reserved.