/** * Copies the contents of this view into the provided set. * * @param <S> the set type * @param set the set for copying the contents */ public <S extends Set<E>> void copyInto(final S set) { CollectionUtils.addAll(set, this); }
/** * Traverses an iterator of this iterable and adds all elements * to the provided collection. * * @param collection the collection to add the elements * @throws NullPointerException if collection is null */ public void copyInto(final Collection<? super E> collection) { if (collection == null) { throw new NullPointerException("Collection must not be null"); } CollectionUtils.addAll(collection, iterable); }
/** * Create a new set operation helper from the two collections. * @param a the first collection * @param b the second collection */ public SetOperationCardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) { super(a, b); elements = new HashSet<>(); addAll(elements, a); addAll(elements, b); // the resulting list must contain at least each unique element, but may grow newList = new ArrayList<>(elements.size()); }
/** * Adds all elements in the {@link Iterable} to the given collection. If the * {@link Iterable} is a {@link Collection} then it is cast and will be * added using {@link Collection#addAll(Collection)} instead of iterating. * * @param <C> the type of object the {@link Collection} contains * @param collection the collection to add to, must not be null * @param iterable the iterable of elements to add, must not be null * @return a boolean indicating whether the collection has changed or not. * @throws NullPointerException if the collection or iterator is null */ public static <C> boolean addAll(final Collection<C> collection, final Iterable<? extends C> iterable) { if (iterable instanceof Collection<?>) { return collection.addAll((Collection<? extends C>) iterable); } return addAll(collection, iterable.iterator()); }
/** * Adds Iterable values to the collection associated with the specified key. * * @param key the key to store against * @param values the values to add to the collection at the key, may not be null * @return true if this map changed * @throws NullPointerException if values is null */ @Override public boolean putAll(final K key, final Iterable<? extends V> values) { if (values == null) { throw new NullPointerException("Values must not be null."); } if (values instanceof Collection<?>) { final Collection<? extends V> valueCollection = (Collection<? extends V>) values; return !valueCollection.isEmpty() && get(key).addAll(valueCollection); } final Iterator<? extends V> it = values.iterator(); return it.hasNext() && CollectionUtils.addAll(get(key), it); }
@Override public boolean putAll(final K key, final Iterable<? extends V> values) { if (values == null) { throw new NullPointerException("Values must not be null."); } final Iterable<V> transformedValues = FluentIterable.of(values).transform(valueTransformer); final Iterator<? extends V> it = transformedValues.iterator(); return it.hasNext() && CollectionUtils.addAll(decorated().get(transformKey(key)), it); }
CollectionUtils.addAll(singlePartition, iterable); return Collections.singletonList(singlePartition);
@Override public NodeOperation then(NodeOperation... childrenOps) { // add the operations to allow multiple calls on the method. CollectionUtils.addAll(this.childrenOps, childrenOps); return this; } }
@Override public NodeOperation then(NodeOperation... childrenOps) { // add the operations to allow multiple calls on the method. CollectionUtils.addAll(this.childrenOps, childrenOps); return this; }
@Override public NodeOperation then(NodeOperation... childrenOps) { // add the operations to allow multiple calls on the method. CollectionUtils.addAll(this.childrenOps, childrenOps); return this; }
@Override public NodeOperation then(NodeOperation... childrenOps) { // add the operations to allow multiple calls on the method. CollectionUtils.addAll(this.childrenOps, childrenOps); return this; } }
/** * @param tags */ public void addTags(String... tags) { CollectionUtils.addAll(includeTags, tags); }
public static <T> T merge(Object... sources) { final ArrayList list = new ArrayList(); CollectionUtils.addAll(list, sources); return (T) merger.merge(list); }
@SafeVarargs public static <V> ListOptions<V> of(V v, V... vs) { List<V> options = new ArrayList<>(); options.add(v); if (vs != null) { CollectionUtils.addAll(options, vs); } return new ListOptions<>(options); }
public static List<ErrorMessage> getCauses(final ErrorMessage message) { List<ErrorMessage> errors = new ArrayList<>(); if (message instanceof CompositeErrorMessage) { Iterator<ErrorMessage> iter = ((CompositeErrorMessage) message).iterator(); CollectionUtils.addAll(errors, iter); } else { errors.add(message); } return errors; }
@Override public Object apply(FeatureKey key) { Object value = backend.valueOf(key); if (isNull(value)) { value = new ArrayList<>(); } else if (value instanceof Object[]) { Object[] array = (Object[]) value; List<Object> list = new ArrayList<>(array.length + ARRAY_SIZE_OFFSET); CollectionUtils.addAll(list, array); value = list; } return value; } }
@Override public Object apply(FeatureKey key) { Object value = backend.valueOf(key); if (isNull(value)) { value = new ArrayList<>(); } else if (value instanceof Object[]) { Object[] array = (Object[]) value; List<Object> list = new ArrayList<>(array.length + ARRAY_SIZE_OFFSET); CollectionUtils.addAll(list, array); value = list; } return value; } }
protected void addStyleForItem(com.vaadin.ui.MenuBar.MenuItem item, String styleName) { List<String> styles = new ArrayList<>(); String style = item.getStyleName(); if (style != null) { CollectionUtils.addAll(styles, style.split(" ")); } if (!styles.contains(styleName)) { styles.add(styleName); } applyStylesForItem(item, styles); }
protected void removeStyleForItem(com.vaadin.ui.MenuBar.MenuItem item, String styleName) { String style = item.getStyleName(); if (style != null) { List<String> styles = new ArrayList<>(); CollectionUtils.addAll(styles, style.split(" ")); styles.remove(styleName); applyStylesForItem(item, styles); } }
public <T> T merge(Object... sources) { final ArrayList<Object> list = new ArrayList<Object>(); CollectionUtils.addAll(list, sources); return (T) proxyBasedBeanMerger.merge(list); }