本文整理了Java中org.apache.commons.collections4.CollectionUtils.emptyCollection()
方法的一些代码示例,展示了CollectionUtils.emptyCollection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.emptyCollection()
方法的具体详情如下:
包路径:org.apache.commons.collections4.CollectionUtils
类名称:CollectionUtils
方法名:emptyCollection
[英]Returns the immutable EMPTY_COLLECTION with generic type safety.
[中]返回具有泛型类型安全性的不可变空\u集合。
代码示例来源:origin: org.apache.commons/commons-collections4
/**
* Returns an immutable empty collection if the argument is <code>null</code>,
* or the argument itself otherwise.
*
* @param <T> the element type
* @param collection the collection, possibly <code>null</code>
* @return an empty collection if the argument is <code>null</code>
*/
public static <T> Collection<T> emptyIfNull(final Collection<T> collection) {
return collection == null ? CollectionUtils.<T>emptyCollection() : collection;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
public static Collection intersection(final Iterable a, final Iterable b) {
Collection response;
if (!IterableUtils.isEmpty(a) && (a instanceof ArrayList) && !IterableUtils.isEmpty(b) && (b instanceof ArrayList)) {
//TODO this is a bit of a hack to allow the intersection of two collections of different types. This is primarily
//used to facilitate some MVEL execution. We really should be fixing the MVEL to call a method that retrieves
//a list of Strings, rather than a list of ValueAssignables.
Object aVal = ((ArrayList) a).get(0);
Object bVal = ((ArrayList) b).get(0);
if (aVal instanceof ValueAssignable && bVal instanceof String) {
response = valueAssignableIntersection(a, b);
} else {
response = CollectionUtils.intersection(a, b);
}
} else {
if (a == null || b == null) {
return CollectionUtils.emptyCollection();
}
response = CollectionUtils.intersection(a, b);
}
return response;
}
内容来源于网络,如有侵权,请联系作者删除!