/** * Checks if this iterable is empty. * * @return true if this iterable does not contain any elements, false otherwise */ public boolean isEmpty() { return IterableUtils.isEmpty(iterable); }
private static Collection<String> valueAssignableIntersection(final Iterable<ValueAssignable> a, final Iterable<String> b) { List<String> temp = new ArrayList<>(); if (!IterableUtils.isEmpty(a)) { for (ValueAssignable alist : a) { temp.add((String) alist.getValue()); } } return CollectionUtils.intersection(temp, b); }
private static Collection intersectIterable(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 { response = CollectionUtils.intersection(a, b); } return response; }
return ((Collection<?>) object).isEmpty(); } else if (object instanceof Iterable<?>) { return IterableUtils.isEmpty((Iterable<?>) object); } else if (object instanceof Map<?, ?>) { return ((Map<?, ?>) object).isEmpty();
public static Collection<String> valueAssignableIntersection(final Iterable<ValueAssignable> a, final Iterable<String> b) { List<String> temp = new ArrayList<>(); if (!IterableUtils.isEmpty(a)) { for (ValueAssignable alist : a) { temp.add((String) alist.getValue()); } } return CollectionUtils.intersection(temp, b); }
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; }