public final class Lang
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
array(T... array)
create new array.
|
static <T> void |
each(java.lang.Iterable<T> iterable,
java.util.function.ObjIntConsumer<T> consumer)
Each.
|
static <T> void |
each(java.util.function.ObjIntConsumer<T> consumer,
T... array)
Each.
|
static <T> void |
each(T[] array,
java.util.function.ObjIntConsumer<T> consumer)
Each.
|
static boolean |
equals(java.lang.Object target,
java.lang.Object otherTarget)
安全的equals,防止空指针异常 .
|
static java.lang.StackTraceElement |
getInvoker()
获取调用getInvoker方法所在的方法被调用的信息(即调用方法、类等).
|
static java.lang.StackTraceElement |
getInvoker(int depth)
获取调用getInvoker方法所在的方法被调用的信息(即调用方法、类等) .
|
static java.util.List<java.lang.StackTraceElement> |
getInvokers()
获取调用此方法的调用方法栈 .
|
static int |
hashCode(java.lang.Object o)
返回hash code,如果传入参数为null,返回0.
|
static <O,R extends O> |
ifEmpty(O object,
java.lang.Iterable<java.util.function.Supplier<R>> suppliers)
判断传入对象是否为empty,使用
isEmpty(Object)判断,
如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回. |
static <O,R extends O> |
ifEmpty(O object,
R defaultObject)
判断传入对象是否为empty,使用
isEmpty(Object)判断. |
static <O,R extends O> |
ifEmpty(O object,
java.util.function.Supplier<R>... suppliers)
判断传入对象是否为empty,使用
isEmpty(Object)判断,
如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回. |
static <O,R extends O> |
ifEmpty(O object,
java.util.function.Supplier<R> supplier)
判断传入对象是否为empty,使用
isEmpty(Object)判断. |
static <O,R extends O> |
ifEmpty(java.util.function.Supplier<O> object,
java.lang.Iterable<java.util.function.Supplier<R>> suppliers)
判断传入对象是否为empty,使用
isEmpty(Object)判断,
如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回. |
static <O,R extends O> |
ifEmpty(java.util.function.Supplier<O> object,
java.util.function.Supplier<R>... suppliers)
判断传入对象是否为empty,使用
isEmpty(Object)判断,
如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回. |
static <O,R extends O> |
ifEmpty(java.util.function.Supplier<O> object,
java.util.function.Supplier<R> supplier)
判断传入对象是否为empty,使用
isEmpty(Object)判断. |
static <O,R> R |
ifEmptyOrElse(O object,
java.util.function.Function<O,R> emptyFunction,
java.util.function.Function<O,R> notEmptyFunction)
判断传入对象是否为空,使用
isEmpty(Object)判断,
如果为空返回参数emptyFunction的执行结果,否则返回参数notEmptyFunction的执行结果. |
static <O,R> R |
ifEmptyOrElse(O object,
java.util.function.Supplier<R> emptySupplier,
java.util.function.Function<O,R> notEmptyFunction)
判断传入对象是否为空,使用
isEmpty(Object)判断,
如果为空返回参数nullSupplier的执行结果,否则返回参数notEmptyFunction的执行结果. |
static void |
ifExists(java.io.File file,
java.util.function.Consumer<java.io.File> consumer)
判断传入文件对象代表的物理文件是否存在,存在则执行传入方法 .
|
static <R> R |
ifExists(java.io.File file,
java.util.function.Function<java.io.File,R> exists,
java.util.function.Function<java.io.File,R> notExists)
判断传入文件对象代表的物理文件是否存在,存在则执行传入方法 .
|
static <R> R |
ifFalse(boolean bool,
java.util.function.Supplier<R> isFalse,
java.util.function.Supplier<R> isTrue)
ifTrue.
|
static <R> R |
ifFalse(java.util.function.BooleanSupplier decideSupplier,
java.util.function.Supplier<R> isFalse,
java.util.function.Supplier<R> isTrue)
ifTrue.
|
static <O> void |
ifNotEmpty(O object,
java.util.function.Consumer<O> consumer)
判断传入对象是否不为空,(String、Collection、Map、Array还要判断长度是否为0),如果不为空则执行传入的方法 .
|
static <O,R> R |
ifNotEmpty(O object,
java.util.function.Function<O,R> notEmptyFunction)
Check (
isNotEmpty(Object)) whether the passed object is not empty. |
static <T> T |
ifNotEmptyFirst(T... objects)
返回第一个非空的对象,使用
isNotEmpty(Object)判断逻辑. |
static <T> T |
ifNotEmptyFirst(T first,
java.util.function.Supplier<T>... suppliers)
返回第一个非空的对象,使用
isNotEmpty(Object)判断逻辑. |
static <O,R> R |
ifNotEmptyOrElse(O object,
java.util.function.Function<O,R> notEmptyFunction,
java.util.function.Function<O,R> emptyFunction)
Check (
isNotEmpty(Object)) whether the passed object is not empty. |
static <O,R> R |
ifNotEmptyOrElse(O object,
java.util.function.Function<O,R> notEmptyFunction,
java.util.function.Supplier<R> emptySupplier)
Check (
isNotEmpty(Object)) whether the passed object is not empty. |
static void |
ifNotExists(java.io.File file,
java.util.function.Consumer<java.io.File> consumer)
判断传入文件对象代表的物理文件是否不存在,不存在则执行传入方法 .
|
static <R> R |
ifNotExists(java.io.File file,
java.util.function.Function<java.io.File,R> notExists,
java.util.function.Function<java.io.File,R> exists)
判断传入文件对象代表的物理文件是否不存在,不存在则执行传入方法 .
|
static <R> R |
ifNotExists(java.io.File file,
java.util.function.Supplier<R> supplier)
判断传入文件对象代表的物理文件是否不存在,不存在则执行传入方法 .
|
static <O,R> R |
ifNotNull(O object,
java.util.function.Function<O,R> notNull)
Determines whether the passed object is not null.
|
static <T> T |
ifNotNullFirst(java.lang.Iterable<T> objects)
返回第一个非空的对象,使用!=null判断逻辑.
|
static <T> T |
ifNotNullFirst(T... objects)
返回第一个非空的对象,使用!=null判断逻辑.
|
static <O,R> R |
ifNotNullOrElse(O object,
java.util.function.Function<O,R> notNullFunction,
java.util.function.Supplier<R> nullSupplier)
Determines(
isNotEmpty(Object)) whether the passed object is not empty. |
static <O,R extends O> |
ifNull(O object,
java.lang.Iterable<java.util.function.Supplier<R>> suppliers)
判断传入对象是否为null,如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回.
|
static <O,R extends O> |
ifNull(O object,
R defaultObject)
如果第一个参数为空(null),返回第二个参数,否则返回第一个参数 .
|
static <O,R extends O> |
ifNull(O object,
java.util.function.Supplier<R>... suppliers)
判断传入对象是否为null,如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回.
|
static <O,R extends O> |
ifNull(O object,
java.util.function.Supplier<R> supplier)
判断传入对象是否为null,如果为空则执行传入的supplier, 并返回其返回值,否则直接返回传入对象.
|
static <O,R extends O> |
ifNull(java.util.function.Supplier<O> object,
java.lang.Iterable<java.util.function.Supplier<R>> suppliers)
判断传入对象是否为null,如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回.
|
static <O,R extends O> |
ifNull(java.util.function.Supplier<O> object,
java.util.function.Supplier<R>... suppliers)
判断传入对象是否为null,如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回.
|
static <O,R extends O> |
ifNull(java.util.function.Supplier<O> object,
java.util.function.Supplier<R> supplier)
判断传入对象是否为null,如果为空则执行传入的方法, 并返回其返回值.
|
static <O,R> R |
ifNullOrElse(O object,
java.util.function.Supplier<R> nullSupplier,
java.util.function.Function<O,R> notNullFunction)
判断传入对象是否为null,如果为null返回参数nullSupplier的执行结果,否则返回参数notNullFunction的执行结果.
|
static <R> R |
ifTrue(boolean bool,
java.util.function.Supplier<R> isTrue,
java.util.function.Supplier<R> isFalse)
ifTrue.
|
static <R> R |
ifTrue(java.util.function.BooleanSupplier decideSupplier,
java.util.function.Supplier<R> isTrue,
java.util.function.Supplier<R> isFalse)
ifTrue.
|
static boolean |
isEmpty(java.util.Collection<?> collection)
返回传入集合是否为空(是null或size=0) .
|
static boolean |
isEmpty(java.util.Map<?,?> map)
返回传入map是否为空(是null或size=0) .
|
static boolean |
isEmpty(java.lang.Object object)
返回传入对象是否为空,(String、Collection、Map、Array还要判断长度是否为0) .
|
static boolean |
isEmpty(java.lang.Object[] array)
返回数组是否为空(是null或是空数组) .
|
static boolean |
isEmpty(java.util.Optional<?> optional)
返回传入Optional是否为空(是null或者内部数据为null) .
|
static boolean |
isEmpty(java.lang.String string)
返回传入字符串是否为空(是null或是空字符串) .
|
static boolean |
isEmpty(java.util.function.Supplier<?> supplier)
返回传入Supplier是否为空(是null或者get()返回值为null) .
|
static boolean |
isExists(java.io.File file)
判断传入文件对象代表的物理文件是否存在 .
|
static boolean |
isFalse(java.lang.Boolean value)
Checks if is false.
|
static boolean |
isNotEmpty(java.util.Collection<?> collection)
返回传入集合是否不为空(不是null或size>0) .
|
static boolean |
isNotEmpty(java.util.Map<?,?> map)
返回传入map是否不为空(不是null或size>0) .
|
static boolean |
isNotEmpty(java.lang.Object object)
返回传入对象是否不为空(String、Collection、Map、Array还要判断长度是否为0) .
|
static boolean |
isNotEmpty(java.lang.Object[] array)
返回数组是否不为空(null或空数组) .
|
static boolean |
isNotEmpty(java.util.Optional<?> optional)
返回传入Optional是否不为空(不是null或者内部数据不为null) .
|
static boolean |
isNotEmpty(java.lang.String string)
返回传入字符串是否不为空(不是null或不是空字符串) .
|
static boolean |
isNotEmpty(java.util.function.Supplier<?> supplier)
返回传入Supplier是否不为空(不是null或者get()返回值不为null) .
|
static boolean |
isNotExists(java.io.File file)
判断传入文件对象代表的物理文件是否不存在 .
|
static boolean |
isNullOrFalse(java.lang.Boolean value)
Checks if is null or false.
|
static boolean |
isNullOrTrue(java.lang.Boolean value)
Checks if is null or true.
|
static boolean |
isTrue(java.lang.Boolean value)
Checks if is true.
|
static <E> java.util.List<E> |
list(E... elements)
craete new list.
|
static <T> T |
pick(T target,
java.util.function.Supplier<T> defaultTarget)
Deprecated.
use
ifNull(Object, Supplier) instead |
static <T> T |
pick(T target,
T defaultTarget)
Deprecated.
|
static <T> T |
pickFirst(java.lang.Iterable<T> objects)
Deprecated.
use
ifNotNullFirst(Iterable) instead |
static <T> T |
pickFirst(T... objects)
Deprecated.
use
ifNotNullFirst(Object...) instead |
static <T> T |
pickLast(java.util.List<T> pickedItems)
返回最后一个非空的对象,!=null .
|
static <T> T |
pickLast(T... pickedItems)
返回最后一个非空的对象,!=null .
|
static <E> java.util.Set<E> |
set(E... elements)
create new set.
|
static <A> A[] |
toArray(java.util.Collection<A> collection)
转换为数组.
|
static <A> A[] |
toArray(java.util.Collection<A> collection,
java.lang.Class<A> type)
转换为数组.
|
static <T extends java.lang.Enum<T>> |
toEnum(java.lang.Class<T> toClass,
java.lang.Object object)
将传入对象转换为枚举 .
|
static <T extends java.lang.Enum<T>> |
toEnum0(java.lang.Class<T> toClass,
java.lang.Object object)
将传入对象转换为枚举 .
|
static <A> java.util.List<A> |
toList(A[] arrays)
转换为列表
|
static <A> java.util.Map<java.lang.Integer,A> |
toMap(A[] arrays)
转换为以数组索引为key,数组值为value的map.
|
static <A> java.util.Map<java.lang.String,A> |
toMap2(A[] arrays)
Deprecated.
use
toMapStringKey(Object...) instead |
static <A> java.util.Map<java.lang.String,A> |
toMapStringKey(A... arrays)
转换为以数组索引为key(string类型),数组值为value的map.
|
static java.lang.String |
toString(java.lang.Object obj)
转换为String,如果不能转换(null)则返回null .
|
static java.lang.String |
toString(java.lang.Object obj,
java.lang.String defaultValue)
转换为String,如果不能转换(null)则使用默认值 .
|
static void |
wrapThrow(java.io.IOException ioException)
Wrap throw.
|
static void |
wrapThrow(java.lang.Throwable throwable)
Wrap throw.
|
static <E extends java.lang.RuntimeException> |
wrapThrow(java.lang.Throwable throwable,
java.lang.Class<E> wrappedRuntimeException)
Wrap throw.
|
@Deprecated
public static <T> T pick(T target,
T defaultTarget)
ifNull(Object, Object)T - the generic typetarget - the targetdefaultTarget - the default target@Deprecated
public static <T> T pick(T target,
java.util.function.Supplier<T> defaultTarget)
ifNull(Object, Supplier) insteadT - the generic typetarget - the targetdefaultTarget - the default target@Deprecated public static <T> T pickFirst(T... objects)
ifNotNullFirst(Object...) insteadT - the generic typeobjects - the objects@Deprecated public static <T> T pickFirst(java.lang.Iterable<T> objects)
ifNotNullFirst(Iterable) insteadT - the generic typeobjects - the objectspublic static <T> T pickLast(T... pickedItems)
T - the generic typepickedItems - the picked itemspublic static <T> T pickLast(java.util.List<T> pickedItems)
T - the generic typepickedItems - the picked itemspublic static boolean isEmpty(java.lang.Object object)
object - the objectpublic static boolean isNotEmpty(java.lang.Object object)
object - the objectpublic static <R> R ifTrue(boolean bool,
java.util.function.Supplier<R> isTrue,
java.util.function.Supplier<R> isFalse)
R - the generic typebool - the boolisTrue - the is trueisFalse - the is falsepublic static <R> R ifTrue(java.util.function.BooleanSupplier decideSupplier,
java.util.function.Supplier<R> isTrue,
java.util.function.Supplier<R> isFalse)
R - the generic typedecideSupplier - the decide supplierisTrue - the is trueisFalse - the is falsepublic static <R> R ifFalse(boolean bool,
java.util.function.Supplier<R> isFalse,
java.util.function.Supplier<R> isTrue)
R - the generic typebool - the boolisFalse - the is falseisTrue - the is truepublic static <R> R ifFalse(java.util.function.BooleanSupplier decideSupplier,
java.util.function.Supplier<R> isFalse,
java.util.function.Supplier<R> isTrue)
R - the generic typedecideSupplier - the decide supplierisFalse - the is falseisTrue - the is truepublic static <O,R extends O> O ifEmpty(O object,
R defaultObject)
isEmpty(Object)判断. 如果为空则返回defaultObject,
否则直接返回传入对象.O - the generic typeR - the generic typeobject - the objectdefaultObject - the default objectpublic static <O,R extends O> O ifEmpty(O object,
java.util.function.Supplier<R> supplier)
isEmpty(Object)判断. 如果为空则执行传入的supplier, 并返回其返回值,
否则直接返回传入对象.O - the generic typeR - the generic typeobject - the objectsupplier - the supplier@SafeVarargs
public static <O,R extends O> O ifEmpty(O object,
java.util.function.Supplier<R>... suppliers)
isEmpty(Object)判断,
如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回.O - the generic typeR - the generic typeobject - the objectsuppliers - the supplierspublic static <O,R extends O> O ifEmpty(O object,
java.lang.Iterable<java.util.function.Supplier<R>> suppliers)
isEmpty(Object)判断,
如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回.O - the generic typeR - the generic typeobject - the objectsuppliers - the supplierspublic static <O,R extends O> O ifEmpty(java.util.function.Supplier<O> object,
java.util.function.Supplier<R> supplier)
isEmpty(Object)判断.
如果为空则执行传入supplier,并返回其执行值,否则直接返回传入对象.O - the generic typeR - the generic typeobject - the objectsupplier - the supplier@SafeVarargs
public static <O,R extends O> O ifEmpty(java.util.function.Supplier<O> object,
java.util.function.Supplier<R>... suppliers)
isEmpty(Object)判断,
如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回.O - the generic typeR - the generic typeobject - the objectsuppliers - the supplierspublic static <O,R extends O> O ifEmpty(java.util.function.Supplier<O> object,
java.lang.Iterable<java.util.function.Supplier<R>> suppliers)
isEmpty(Object)判断,
如果为空则迭代suppliers并执行,如果其返回对象不是null,则返回.O - the generic typeR - the generic typeobject - the objectsuppliers - the supplierspublic static <O,R> R ifEmptyOrElse(O object,
java.util.function.Function<O,R> emptyFunction,
java.util.function.Function<O,R> notEmptyFunction)
isEmpty(Object)判断,
如果为空返回参数emptyFunction的执行结果,否则返回参数notEmptyFunction的执行结果.O - the generic typeR - the generic typeobject - the objectemptyFunction - the empty functionnotEmptyFunction - the not empty functionpublic static <O,R> R ifEmptyOrElse(O object,
java.util.function.Supplier<R> emptySupplier,
java.util.function.Function<O,R> notEmptyFunction)
isEmpty(Object)判断,
如果为空返回参数nullSupplier的执行结果,否则返回参数notEmptyFunction的执行结果.O - the generic typeR - the generic typeobject - the objectemptySupplier - the empty suppliernotEmptyFunction - the not empty functionpublic static <T> T ifNotNullFirst(T... objects)
T - the generic typeobjects - the objectspublic static <T> T ifNotNullFirst(java.lang.Iterable<T> objects)
T - the generic typeobjects - the objectspublic static <O,R> R ifNotNull(O object,
java.util.function.Function<O,R> notNull)
O - the generic typeR - the generic typeobject - the objectnotNull - the not nullpublic static <O,R> R ifNotNullOrElse(O object,
java.util.function.Function<O,R> notNullFunction,
java.util.function.Supplier<R> nullSupplier)
isNotEmpty(Object)) whether the passed object is not empty. If it is not
empty, the result of the
function parameter is returned. If it is not empty, the result of the supplier parameter is
returned.
isNotEmpty(Object))传入对象是否不为空,不为空则返回参数function的执行结果,否则返回参数supplier的执行结果.O - the generic typeR - the generic typeobject - the objectnotNullFunction - the not null functionnullSupplier - the null supplierpublic static <O,R extends O> O ifNull(O object,
R defaultObject)
O - the generic typeR - the generic typeobject - the objectdefaultObject - the default objectpublic static <O,R extends O> O ifNull(O object,
java.util.function.Supplier<R> supplier)
O - the generic typeR - the generic typeobject - the objectsupplier - the supplier@SafeVarargs
public static <O,R extends O> O ifNull(O object,
java.util.function.Supplier<R>... suppliers)
O - the generic typeR - the generic typeobject - the objectsuppliers - the supplierspublic static <O,R extends O> O ifNull(O object,
java.lang.Iterable<java.util.function.Supplier<R>> suppliers)
O - the generic typeR - the generic typeobject - the objectsuppliers - the supplierspublic static <O,R extends O> O ifNull(java.util.function.Supplier<O> object,
java.util.function.Supplier<R> supplier)
O - the generic typeR - the generic typeobject - the objectsupplier - the supplier@SafeVarargs
public static <O,R extends O> O ifNull(java.util.function.Supplier<O> object,
java.util.function.Supplier<R>... suppliers)
O - the generic typeR - the generic typeobject - the objectsuppliers - the supplierspublic static <O,R extends O> O ifNull(java.util.function.Supplier<O> object,
java.lang.Iterable<java.util.function.Supplier<R>> suppliers)
O - the generic typeR - the generic typeobject - the objectsuppliers - the supplierspublic static <O,R> R ifNullOrElse(O object,
java.util.function.Supplier<R> nullSupplier,
java.util.function.Function<O,R> notNullFunction)
O - the generic typeR - the generic typeobject - the objectnullSupplier - the null suppliernotNullFunction - the not null functionpublic static <T> T ifNotEmptyFirst(T... objects)
isNotEmpty(Object)判断逻辑.T - the generic typeobjects - the objectspublic static <T> T ifNotEmptyFirst(T first,
java.util.function.Supplier<T>... suppliers)
isNotEmpty(Object)判断逻辑.T - the generic typefirst - the firstsuppliers - the supplierspublic static <O,R> R ifNotEmpty(O object,
java.util.function.Function<O,R> notEmptyFunction)
isNotEmpty(Object)) whether the passed object is not empty. If it is not
empty, the passed function is executed; otherwise, null is returned.
判断(isNotEmpty(Object))传入对象是否不为空,不为空则执行传入的function,否则返回null.O - the generic typeR - the generic typeobject - the objectnotEmptyFunction - the not empty functionpublic static <O,R> R ifNotEmptyOrElse(O object,
java.util.function.Function<O,R> notEmptyFunction,
java.util.function.Function<O,R> emptyFunction)
isNotEmpty(Object)) whether the passed object is not empty. If it is not
empty, the result of the first argument (notEmptyFunction) is returned. * Otherwise, the
result of the second argument (emptyFunction) is returned.
isNotEmpty(Object))传入对象是否不为空,不为空则返回第一个参数(notEmptyFunction)的执行结果,
否则返回第二个参数(emptyFunction)的执行结果.O - the generic typeR - the generic typeobject - the objectnotEmptyFunction - the not empty functionemptyFunction - the empty functionpublic static <O,R> R ifNotEmptyOrElse(O object,
java.util.function.Function<O,R> notEmptyFunction,
java.util.function.Supplier<R> emptySupplier)
isNotEmpty(Object)) whether the passed object is not empty. If it is not
empty, the result of the first argument (notEmptyFunction) is returned. * Otherwise, the
result of the second argument (emptySupplier) is returned.
isNotEmpty(Object))传入对象是否不为空,不为空则返回第一个参数(notEmptyFunction)的执行结果,
否则返回第二个参数(emptySupplier)的执行结果.O - the generic typeR - the generic typeobject - the objectnotEmptyFunction - the not empty functionemptySupplier - the empty supplierpublic static <O> void ifNotEmpty(O object,
java.util.function.Consumer<O> consumer)
O - the generic typeobject - 传入的对象consumer - 需要执行的方法public static boolean isEmpty(java.util.Optional<?> optional)
optional - the optionalpublic static boolean isEmpty(java.util.function.Supplier<?> supplier)
supplier - the supplierpublic static boolean isNotEmpty(java.util.Optional<?> optional)
optional - the optionalpublic static boolean isNotEmpty(java.util.function.Supplier<?> supplier)
supplier - the supplierpublic static boolean isEmpty(java.lang.String string)
string - the stringpublic static boolean isNotEmpty(java.lang.String string)
string - the stringpublic static boolean isEmpty(java.lang.Object[] array)
array - the arraypublic static boolean isNotEmpty(java.lang.Object[] array)
array - the arraypublic static boolean isEmpty(java.util.Collection<?> collection)
collection - the collectionpublic static boolean isNotEmpty(java.util.Collection<?> collection)
collection - the collectionpublic static boolean isEmpty(java.util.Map<?,?> map)
map - the mappublic static boolean isNotEmpty(java.util.Map<?,?> map)
map - the mappublic static boolean isTrue(java.lang.Boolean value)
value - the valuepublic static boolean isNullOrTrue(java.lang.Boolean value)
value - the valuepublic static boolean isFalse(java.lang.Boolean value)
value - the valuepublic static boolean isNullOrFalse(java.lang.Boolean value)
value - the valuepublic static boolean isExists(java.io.File file)
file - the filepublic static boolean isNotExists(java.io.File file)
file - the filepublic static void ifExists(java.io.File file,
java.util.function.Consumer<java.io.File> consumer)
file - 判断的文件consumer - 需要执行的方法public static <R> R ifExists(java.io.File file,
java.util.function.Function<java.io.File,R> exists,
java.util.function.Function<java.io.File,R> notExists)
R - the generic typefile - the fileexists - the existsnotExists - the not existspublic static void ifNotExists(java.io.File file,
java.util.function.Consumer<java.io.File> consumer)
file - 判断的文件consumer - 需要执行的方法public static <R> R ifNotExists(java.io.File file,
java.util.function.Function<java.io.File,R> notExists,
java.util.function.Function<java.io.File,R> exists)
R - the generic typefile - the filenotExists - the not existsexists - the existspublic static <R> R ifNotExists(java.io.File file,
java.util.function.Supplier<R> supplier)
R - the generic typefile - the filesupplier - the supplierpublic static <T extends java.lang.Enum<T>> T toEnum(java.lang.Class<T> toClass,
java.lang.Object object)
T - the generic typetoClass - the to classobject - the objectpublic static <T extends java.lang.Enum<T>> T toEnum0(java.lang.Class<T> toClass,
java.lang.Object object)
T - the generic typetoClass - the to classobject - the objectpublic static boolean equals(java.lang.Object target,
java.lang.Object otherTarget)
target - the targetotherTarget - the other targetpublic static int hashCode(java.lang.Object o)
o - the oObject.hashCode()public static java.lang.String toString(java.lang.Object obj,
java.lang.String defaultValue)
obj - the objdefaultValue - the default valuepublic static java.lang.String toString(java.lang.Object obj)
obj - the objpublic static java.lang.StackTraceElement getInvoker()
public static java.lang.StackTraceElement getInvoker(int depth)
depth - the depthpublic static java.util.List<java.lang.StackTraceElement> getInvokers()
public static <A> A[] toArray(java.util.Collection<A> collection)
A - the generic typecollection - the collectionpublic static <A> A[] toArray(java.util.Collection<A> collection,
java.lang.Class<A> type)
转换为数组. 如果传入集合为空(null或者size=0),返回长度为0的数组(不会返回null).
A - the generic typecollection - the collectiontype - the typepublic static <A> java.util.List<A> toList(A[] arrays)
转换为列表
.A - the generic typearrays - the arrayspublic static <A> java.util.Map<java.lang.Integer,A> toMap(A[] arrays)
A - the generic typearrays - the arrays@Deprecated public static <A> java.util.Map<java.lang.String,A> toMap2(A[] arrays)
toMapStringKey(Object...) insteadA - the generic typearrays - the arrayspublic static <A> java.util.Map<java.lang.String,A> toMapStringKey(A... arrays)
A - the generic typearrays - the arrayspublic static void wrapThrow(java.lang.Throwable throwable)
throwable - the throwablepublic static void wrapThrow(java.io.IOException ioException)
ioException - the io exceptionpublic static <E extends java.lang.RuntimeException> void wrapThrow(java.lang.Throwable throwable,
java.lang.Class<E> wrappedRuntimeException)
E - the element typethrowable - the throwablewrappedRuntimeException - the wrapped runtime exceptionpublic static <T> void each(T[] array,
java.util.function.ObjIntConsumer<T> consumer)
T - the generic typearray - the arrayconsumer - the consumerpublic static <T> void each(java.util.function.ObjIntConsumer<T> consumer,
T... array)
T - the generic typeconsumer - the consumerarray - the arraypublic static <T> void each(java.lang.Iterable<T> iterable,
java.util.function.ObjIntConsumer<T> consumer)
T - the generic typeiterable - the iterableconsumer - the consumerpublic static <T> T[] array(T... array)
T - the generic typearray - the arraypublic static <E> java.util.List<E> list(E... elements)
E - the element typeelements - the elementspublic static <E> java.util.Set<E> set(E... elements)
E - the element typeelements - the elements