程序包 com.ajaxjs.util
类 ObjectHelper
java.lang.Object
com.ajaxjs.util.ObjectHelper
A helper for Java Object.
-
字段概要
字段修饰符和类型字段说明static final floatDummy Map -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static intgetInitialCapacity(int expectedSize) Creates a HashMap with a specified expected number of entries.static booleanstatic booleanDetermine whether the given array is empty: i.e.static booleanisEmpty(Collection<?> collection) Returntrueif the supplied Collection isnullor empty.static booleanReturntrueif the supplied Map isnullor empty.static booleanisEmptyText(String str) static <T> List<T> listOf(T... arr) Input multiple elements and returns a list of those elements.static <K,V> Map <K, V> mapOf(int expectedSize) static <K,V> Map <K, V> mapOf(K k1, V v1) 创建一个新的 HashMapstatic <K,V> Map <K, V> mapOf(K k1, V v1, K k2, V v2) 创建一个新的 HashMapstatic <K,V> Map <K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3) 创建一个新的 HashMapstatic <T> Set<T> setOf(T... elements) 创建一个不可变的 Set,类似于 Java 9+ 的 Set.of() 支持可变参数,自动去重,返回不可修改的集合
-
字段详细资料
-
EMPTY_PARAMS_MAP
Dummy Map -
DEFAULT_LOAD_FACTOR
public static final float DEFAULT_LOAD_FACTOR- 另请参阅:
-
-
构造器详细资料
-
ObjectHelper
public ObjectHelper()
-
-
方法详细资料
-
hasText
-
isEmptyText
-
isEmpty
Determine whether the given array is empty: i.e.nullor of zero length.- 参数:
array- the array to check
-
isEmpty
Returntrueif the supplied Collection isnullor empty. Otherwise, returnfalse.- 参数:
collection- the Collection to check- 返回:
- whether the given Collection is empty
-
isEmpty
Returntrueif the supplied Map isnullor empty. Otherwise, returnfalse.- 参数:
map- the Map to check- 返回:
- whether the given Map is empty
-
mapOf
创建一个新的 HashMap- 类型参数:
K- k1 类型V- v1 类型- 参数:
k1- 键1v1- 值1- 返回:
- 新创建的 HashMap
-
mapOf
创建一个新的 HashMap- 类型参数:
K- k1 类型V- v1 类型- 参数:
k1- 键1v1- 值1k2- 键2v2- 值2- 返回:
- 新创建的 HashMap
-
mapOf
创建一个新的 HashMap- 类型参数:
K- k1 类型V- v1 类型- 参数:
k1- 键1v1- 值1k2- 键2v2- 值2k3- 键3v3- 值3- 返回:
- 新创建的 HashMap
-
getInitialCapacity
public static int getInitialCapacity(int expectedSize) Creates a HashMap with a specified expected number of entries. The initial capacity and load factor are calculated to minimize resizing.- 参数:
expectedSize- the expected number of entries in the map- 返回:
- a new HashMap with optimal initial capacity and load factor
-
mapOf
-
listOf
Input multiple elements and returns a list of those elements. Just like `List.of()` in Java 9.- 类型参数:
T- The type of the elements- 参数:
arr- The elements- 返回:
- A new list containing the elements of the array
-
setOf
创建一个不可变的 Set,类似于 Java 9+ 的 Set.of() 支持可变参数,自动去重,返回不可修改的集合- 类型参数:
T- 元素类型- 参数:
elements- 元素可变参数- 返回:
- 不可变的 Set
- 抛出:
IllegalArgumentException- 如果传入 null 元素
-