List of usage examples for java.util Collections addAll
@SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements)
From source file:com.imaginary.home.controller.CommandList.java
public CommandList(@Nonnull String serviceId, @Nonnull JSONObject... commands) { this.serviceId = serviceId; this.commands = new ArrayList<JSONObject>(); Collections.addAll(this.commands, commands); }
From source file:Main.java
/** * Create a {@link Collection} of {@link E} and add {@code elements} to the {@link Collection}. * * @param factory Collection factory method. * @param elements Elements to add to collection. * @param <E> Element type./*from ww w . ja v a2 s. co m*/ * @param <T> Collection type. * @return {@link T Collection} of {@link E} with {@code elements}. */ @SafeVarargs public static <E, T extends Collection<E>> T collectionOf(Supplier<T> factory, E... elements) { T collection = factory.get(); Collections.addAll(collection, elements); return collection; }
From source file:Main.java
public static <T> List<T> asList(final T t, final T... ts) { final ArrayList<T> list = new ArrayList<T>(ts.length + 1); list.add(t);// w w w. ja va 2 s . c om Collections.addAll(list, ts); return list; }
From source file:io.netty.handler.codec.mqtt.MqttSubAckPayload.java
public MqttSubAckPayload(MqttGrantedQoS... grantedQoSLevels) { if (grantedQoSLevels == null) { throw new IllegalArgumentException("Empty grantedQoSLevels"); }//from ww w . j a v a 2 s .c o m List<MqttGrantedQoS> list = new ArrayList<>(grantedQoSLevels.length); Collections.addAll(list, grantedQoSLevels); this.grantedQoSLevels = Collections.unmodifiableList(list); }
From source file:de.tor.tribes.util.AllyUtils.java
public static Ally[] filterAllies(Ally[] pAllies, String pFilter, Comparator<Ally> pComparator) { List<Ally> result = new LinkedList<>(); if (pFilter == null || pFilter.length() == 0) { Collections.addAll(result, pAllies); } else {//from ww w . j a va2 s.c om String filter = pFilter.toLowerCase(); for (Ally a : pAllies) { if (a.getName().toLowerCase().contains(filter) || a.getTag().toLowerCase().contains(filter)) { result.add(a); } } } if (pComparator != null) { Collections.sort(result, pComparator); } return result.toArray(new Ally[result.size()]); }
From source file:im.dadoo.cedar.SelectCriteria.java
public SelectCriteria select(String... fields) { Collections.addAll(this.fields, fields); return this; }
From source file:com.thoughtworks.go.domain.scm.SCMs.java
public SCMs(SCM... scms) { Collections.addAll(this, scms); }
From source file:Main.java
/** * Creates a new {@code cl} instance (limited to things implementing * {@link Collection}) populated with the {@literal "varargs"}. Useful if * you truly despise {@link #arr(Object...)}, {@link #list(Object...)}, * or {@link #set(Object...)}./*w w w . j av a 2s. c om*/ * * <p>Example: {@code Collection<Integer> ints = collect(PriorityBlockingQueue.class, 1, 2, 3);} * * @param cl A (non-abstract!) class that implements {@code Collection}. Cannot be {@code null}. * @param elements Objects that will be added to the collection. * * @return An instance of {@code cl} containing the given objects. * * @throws RuntimeException * if {@link java.lang.reflect.Constructor#newInstance(Object...) Constructor#newInstance(Object...)} * had problems. * * @see #arr(Object...) * @see #list(Object...) * @see #set(Object...) */ @SuppressWarnings({ "unchecked", "rawtypes" }) // the only things being added to the collection are objects of type "E" public static <E> Collection<E> collect(Class<? extends Collection> cl, E... elements) { try { Collection<E> c = cl.getConstructor().newInstance(); Collections.addAll(c, elements); return c; } catch (Exception e) { throw new RuntimeException("Problem creating a new " + cl, e); } }
From source file:org.neo4j.nlp.examples.sentiment.main.java
private static Stack<Integer> getRandomizedIndex(int lowerBound, int upperBound) { List<Integer> randomIndex = new ArrayList<>(); Collections.addAll(randomIndex, ArrayUtils.toObject(IntStream.range(lowerBound, upperBound).toArray())); //randomIndex.sort((a, b) -> new Random().nextInt(2) == 0 ? -1 : 1 ); Stack<Integer> integerStack = new Stack<>(); integerStack.addAll(randomIndex);/*from w w w. j av a 2s . c o m*/ return integerStack; }
From source file:com.asakusafw.testdriver.compiler.util.DeploymentUtil.java
/** * Deploys an artifact onto the directory. * @param source the source file/directory * @param destination the target path// ww w. ja v a 2 s . c o m * @param options the deployment options * @throws IOException if I/O error was occurred */ public static void deploy(File source, File destination, DeployOption... options) throws IOException { Objects.requireNonNull(source); Objects.requireNonNull(destination); Objects.requireNonNull(options); Set<DeployOption> opts = EnumSet.noneOf(DeployOption.class); Collections.addAll(opts, options); if (opts.contains(DeployOption.DELETE_SOURCE)) { move(source, destination); } else { copy(source, destination); } }