程序包 com.ajaxjs.util

类 ObjectHelper

java.lang.Object
com.ajaxjs.util.ObjectHelper

public class ObjectHelper extends Object
A helper for Java Object.
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final float
     
    static final Map<String,Object>
    Dummy Map
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static int
    getInitialCapacity(int expectedSize)
    Creates a HashMap with a specified expected number of entries.
    static boolean
     
    static boolean
    isEmpty(Object[] array)
    Determine whether the given array is empty: i.e.
    static boolean
    isEmpty(Collection<?> collection)
    Return true if the supplied Collection is null or empty.
    static boolean
    isEmpty(Map<?,?> map)
    Return true if the supplied Map is null or empty.
    static boolean
     
    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)
    创建一个新的 HashMap
    static <K, V> Map<K,V>
    mapOf(K k1, V v1, K k2, V v2)
    创建一个新的 HashMap
    static <K, V> Map<K,V>
    mapOf(K k1, V v1, K k2, V v2, K k3, V v3)
    创建一个新的 HashMap
    static <T> Set<T>
    setOf(T... elements)
    创建一个不可变的 Set,类似于 Java 9+ 的 Set.of() 支持可变参数,自动去重,返回不可修改的集合

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • EMPTY_PARAMS_MAP

      public static final Map<String,Object> EMPTY_PARAMS_MAP
      Dummy Map
    • DEFAULT_LOAD_FACTOR

      public static final float DEFAULT_LOAD_FACTOR
      另请参阅:
  • 构造器详细资料

    • ObjectHelper

      public ObjectHelper()
  • 方法详细资料

    • hasText

      public static boolean hasText(String str)
    • isEmptyText

      public static boolean isEmptyText(String str)
    • isEmpty

      public static boolean isEmpty(Object[] array)
      Determine whether the given array is empty: i.e. null or of zero length.
      参数:
      array - the array to check
    • isEmpty

      public static boolean isEmpty(Collection<?> collection)
      Return true if the supplied Collection is null or empty. Otherwise, return false.
      参数:
      collection - the Collection to check
      返回:
      whether the given Collection is empty
    • isEmpty

      public static boolean isEmpty(Map<?,?> map)
      Return true if the supplied Map is null or empty. Otherwise, return false.
      参数:
      map - the Map to check
      返回:
      whether the given Map is empty
    • mapOf

      public static <K, V> Map<K,V> mapOf(K k1, V v1)
      创建一个新的 HashMap
      类型参数:
      K - k1 类型
      V - v1 类型
      参数:
      k1 - 键1
      v1 - 值1
      返回:
      新创建的 HashMap
    • mapOf

      public static <K, V> Map<K,V> mapOf(K k1, V v1, K k2, V v2)
      创建一个新的 HashMap
      类型参数:
      K - k1 类型
      V - v1 类型
      参数:
      k1 - 键1
      v1 - 值1
      k2 - 键2
      v2 - 值2
      返回:
      新创建的 HashMap
    • mapOf

      public static <K, V> Map<K,V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3)
      创建一个新的 HashMap
      类型参数:
      K - k1 类型
      V - v1 类型
      参数:
      k1 - 键1
      v1 - 值1
      k2 - 键2
      v2 - 值2
      k3 - 键3
      v3 - 值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

      public static <K, V> Map<K,V> mapOf(int expectedSize)
    • listOf

      @SafeVarargs public static <T> List<T> listOf(T... arr)
      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

      @SafeVarargs public static <T> Set<T> setOf(T... elements)
      创建一个不可变的 Set,类似于 Java 9+ 的 Set.of() 支持可变参数,自动去重,返回不可修改的集合
      类型参数:
      T - 元素类型
      参数:
      elements - 元素可变参数
      返回:
      不可变的 Set
      抛出:
      IllegalArgumentException - 如果传入 null 元素