當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SpringBoot 自带工具类~CollectionUtils
生活随笔
收集整理的這篇文章主要介紹了
SpringBoot 自带工具类~CollectionUtils
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
org.springframework.util.CollectionUtils
1、集合判斷工具
// 判斷 List/Set 是否為空 boolean isEmpty(Collection<?> collection) // 判斷 Map 是否為空 boolean isEmpty(Map<?,?> map) // 判斷 List/Set 中是否包含某個(gè)對(duì)象 boolean containsInstance(Collection<?> collection, Object element) // 以迭代器的方式,判斷 List/Set 中是否包含某個(gè)對(duì)象 boolean contains(Iterator<?> iterator, Object element) // 判斷 List/Set 是否包含某些對(duì)象中的任意一個(gè) boolean containsAny(Collection<?> source, Collection<?> candidates) // 判斷 List/Set 中的每個(gè)元素是否唯一。即 List/Set 中不存在重復(fù)元素 boolean hasUniqueObject(Collection<?> collection)2、集合操作工具
// 將 Array 中的元素都添加到 List/Set 中 <E> void mergeArrayIntoCollection(Object array, Collection<E> collection) // 將 Properties 中的鍵值對(duì)都添加到 Map 中 <K,V> void mergePropertiesIntoMap(Properties props, Map<K,V> map) // 返回 List 中最后一個(gè)元素 <T> T lastElement(List<T> list) // 返回 Set 中最后一個(gè)元素 <T> T lastElement(Set<T> set) // 返回參數(shù) candidates 中第一個(gè)存在于參數(shù) source 中的元素 <E> E findFirstMatch(Collection<?> source, Collection<E> candidates) // 返回 List/Set 中指定類型的元素。 <T> T findValueOfType(Collection<?> collection, Class<T> type) // 返回 List/Set 中指定類型的元素。如果第一種類型未找到,則查找第二種類型,以此類推 Object findValueOfType(Collection<?> collection, Class<?>[] types) // 返回 List/Set 中元素的類型 Class<?> findCommonElementType(Collection<?> collection)總結(jié)
以上是生活随笔為你收集整理的SpringBoot 自带工具类~CollectionUtils的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python 操作 Elasticsea
- 下一篇: 在 VC++ 中使用 内联汇编