org.apache.commons.collections4.CollectionUtils.addAll()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中org.apache.commons.collections4.CollectionUtils.addAll()方法的一些代码示例,展示了CollectionUtils.addAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.addAll()方法的具体详情如下:
包路径:org.apache.commons.collections4.CollectionUtils
类名称:CollectionUtils
方法名:addAll

CollectionUtils.addAll介绍

[英]Adds all elements in the Iterable to the given collection. If the Iterable is a Collection then it is cast and will be added using Collection#addAll(Collection) instead of iterating.
[中]将Iterable中的所有元素添加到给定集合。如果Iterable是一个集合,那么它将被强制转换,并将使用Collection#addAll(Collection)而不是迭代来添加。

代码示例

代码示例来源:origin: org.apache.commons/commons-collections4

/**
 * 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);
}

代码示例来源:origin: org.apache.commons/commons-collections4

/**
 * 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);
}

代码示例来源:origin: org.apache.commons/commons-collections4

/**
 * 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());
}

代码示例来源:origin: org.apache.commons/commons-collections4

/**
 * 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());
}

代码示例来源:origin: org.apache.commons/commons-collections4

/**
 * 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);
}

代码示例来源:origin: org.apache.commons/commons-collections4

@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);
}

代码示例来源:origin: org.apache.commons/commons-collections4

CollectionUtils.addAll(singlePartition, iterable);
return Collections.singletonList(singlePartition);

代码示例来源:origin: info.magnolia/magnolia-core

@Override
  public NodeOperation then(NodeOperation... childrenOps) {
    // add the operations to allow multiple calls on the method.
    CollectionUtils.addAll(this.childrenOps, childrenOps);
    return this;
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public NodeOperation then(NodeOperation... childrenOps) {
  // add the operations to allow multiple calls on the method.
  CollectionUtils.addAll(this.childrenOps, childrenOps);
  return this;
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public NodeOperation then(NodeOperation... childrenOps) {
  // add the operations to allow multiple calls on the method.
  CollectionUtils.addAll(this.childrenOps, childrenOps);
  return this;
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
  public NodeOperation then(NodeOperation... childrenOps) {
    // add the operations to allow multiple calls on the method.
    CollectionUtils.addAll(this.childrenOps, childrenOps);
    return this;
  }
}

代码示例来源:origin: io.wcm.qa/io.wcm.qa.galenium.providers

/**
 * @param tags
 */
public void addTags(String... tags) {
 CollectionUtils.addAll(includeTags, tags);
}

代码示例来源:origin: info.magnolia/magnolia-core

public static <T> T merge(Object... sources) {
  final ArrayList list = new ArrayList();
  CollectionUtils.addAll(list, sources);
  return (T) merger.merge(list);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@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);
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-vaadin-common-widgets

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;
}

代码示例来源:origin: fr.inria.atlanmod.neoemf/neoemf-data-mapdb

@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;
  }
}

代码示例来源:origin: fr.inria.atlanmod.neoemf/neoemf-data-berkeleydb

@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;
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

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);
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

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);
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

public <T> T merge(Object... sources) {
  final ArrayList<Object> list = new ArrayList<Object>();
  CollectionUtils.addAll(list, sources);
  return (T) proxyBasedBeanMerger.merge(list);
}

相关文章