List of usage examples for org.apache.commons.lang3 Validate noNullElements
public static <T extends Iterable<?>> T noNullElements(final T iterable, final String message, final Object... values)
Validate that the specified argument iterable is neither null nor contains any elements that are null ; otherwise throwing an exception with the specified message.
From source file:com.feilong.core.util.SortUtil.java
/** * ? <code>list</code>,(?)?. * // w ww . j av a 2 s .c o m * <h3>:</h3> * * <blockquote> * * <pre class="code"> * * List{@code <User>} list = new ArrayList{@code <User>}(); * list.add(new User(12L, 18)); * list.add(new User(2L, 36)); * list.add(new User(2L, 2)); * list.add(new User(2L, 30)); * list.add(new User(1L, 8)); * SortUtil.sort(list, "id", "age"); * LOGGER.debug(JsonUtil.formatWithIncludes(list, "id", "age")); * * </pre> * * <b>:</b> * * <pre class="code"> [{"id": 1,"age": 8}, {"id": 2,"age": 2}, {"id": 2,"age": 30}, {"id": 2,"age": 36}, {"id": 12,"age": 18}] * </pre> * * </blockquote> * * @param <O> * the generic type * @param list * the list * @param propertyNames * O??,Possibly indexed and/or nested name of the property to be modified,?? * <a href="../bean/BeanUtil.html#propertyName">propertyName</a> * @return <code>list</code> null, {@link Collections#emptyList()}<br> * @throws NullPointerException * <code>propertyNames</code> null * @throws IllegalArgumentException * <code>propertyNames</code> empty , null * @see BeanComparatorUtil#chainedComparator(String...) * @see org.apache.commons.collections4.ComparatorUtils#chainedComparator(java.util.Comparator...) * @see #sort(List, Comparator) */ public static <O> List<O> sort(List<O> list, String... propertyNames) { if (null == list) { return emptyList(); } Validate.notEmpty(propertyNames, "propertyNames can't be null/empty!"); Validate.noNullElements(propertyNames, "propertyName:%s has empty value", propertyNames); return sort(list, BeanComparatorUtil.chainedComparator(propertyNames)); }