Example usage for com.google.common.collect Iterables addAll

List of usage examples for com.google.common.collect Iterables addAll

Introduction

In this page you can find the example usage for com.google.common.collect Iterables addAll.

Prototype

public static <T> boolean addAll(Collection<T> addTo, Iterable<? extends T> elementsToAdd) 

Source Link

Document

Adds all elements in iterable to collection .

Usage

From source file:org.opentestsystem.shared.security.domain.SbacUser.java

public Collection<SbacRole> getNonEffectiveRoles() {
    Collection<SbacRole> roles = new ArrayList<>();
    for (Collection<SbacRole> sbacRoles : sbacRolesMap.values()) {
        Iterables.addAll(roles, Iterables.filter(sbacRoles,
                Predicates.not(RolesAndPermissionsServiceImpl.ROLE_APPLICABLE_TO_COMPONENT_FILTER)));
    }//from   w  w w .  j a  v a2s. co  m
    return roles;
}

From source file:com.zimbra.soap.admin.message.FixCalendarTZRequest.java

public void setAccounts(Iterable<NamedElement> accounts) {
    this.accounts.clear();
    if (accounts != null) {
        Iterables.addAll(this.accounts, accounts);
    }/*  w  w  w.j a v a 2s. c o m*/
}

From source file:uk.co.unclealex.process.builder.BasicProcessRequest.java

/**
 * Prepare and execute a process./*from  w w w. j av a2  s .  c o m*/
 * 
 * @param command
 *          The command to process.
 * @param processCallbacks
 *          The {@link ProcessCallback}s to call.
 * @param arguments
 *          The arguments to supply to the command.
 * @param standardInputSupplier
 *          The {@link StandardInputSupplier} to provide data to standard
 *          input.
 * @return A {@link Callable} which, when executed, will return a
 *         {@link ProcessResult} containing the return value, output and
 *         error.
 * @throws IOException
 *           Thrown if there is an unexpected issue calling the command.
 */
public final Callable<ProcessResult> execute(String command, Iterable<ProcessCallback> processCallbacks,
        Iterable<String> arguments, StandardInputSupplier standardInputSupplier) throws IOException {
    final ProcessCallback processCallback = new ChainingProcessCallback(processCallbacks);
    final List<String> commandline = Lists.newArrayList();
    commandline.add(command);
    Iterables.addAll(commandline, arguments);
    ProcessBuilder processBuilder = new ProcessBuilder(commandline);
    final Process process = processBuilder.start();
    String threadName = Joiner.on(' ').join(processBuilder.command());
    final StreamGobbler stdoutStreamGobbler = new StdoutStreamGobbler(process, threadName, processCallback);
    final StreamGobbler stderrStreamGobbler = new StderrStreamGobbler(process, threadName, processCallback);
    ExecutorService executor = getExecutor();
    final Future<String> stdoutFuture = executor.submit(stdoutStreamGobbler);
    final Future<String> stderrFuture = executor.submit(stderrStreamGobbler);
    try {
        final OutputStream stdin = process.getOutputStream();
        if (standardInputSupplier != null) {
            standardInputSupplier.setStandardInputStream(stdin);
        }
        Callable<ProcessResult> processExecution = new Callable<ProcessResult>() {
            @Override
            public ProcessResult call() throws IOException {
                try {
                    process.waitFor();
                    int returnCode = process.exitValue();
                    processCallback.processFinished(returnCode);
                    String output = stdoutFuture.get();
                    String error = stderrFuture.get();
                    return new ProcessResult(returnCode, output, error);
                } catch (InterruptedException e) {
                    log.warn("Process " + Joiner.on(' ').join(commandline) + " was interrupted.", e);
                    throw new IOException("Process " + Joiner.on(' ').join(commandline) + " was interrupted.",
                            e);
                } catch (ExecutionException e) {
                    log.warn("Process " + Joiner.on(' ').join(commandline) + " errored unexpectedly.", e);
                    throw new IOException(
                            "Process " + Joiner.on(' ').join(commandline) + " errored unexpectedly.", e);
                } finally {
                    Closeables.closeQuietly(stdin);
                    Closeables.closeQuietly(stderrStreamGobbler);
                    Closeables.closeQuietly(stdoutStreamGobbler);
                }
            }
        };
        return processExecution;
    } catch (IOException e) {
        throw new IOException("The process " + Joiner.on(' ').join(commandline) + " failed.", e);
    }
}

From source file:org.jclouds.demo.tweetstore.controller.AddTweetsController.java

public List<StoredTweetStatus> apply(Set<String> in) {
    List<StoredTweetStatus> statuses = Lists.newArrayList();
    for (Iterable<StoredTweetStatus> list : Iterables.transform(in, blobStoreContextToContainerResult)) {
        Iterables.addAll(statuses, list);
    }//from  w  w w. ja  v  a2 s . co  m
    return statuses;
}

From source file:com.google.testing.compile.JavaSourcesSubject.java

@Override
public JavaSourcesSubject withCompilerOptions(Iterable<String> options) {
    Iterables.addAll(this.options, options);
    return this;
}

From source file:org.dcache.pool.nearline.tar.TarNearlineStorage.java

@Override
public void flush(Iterable<FlushRequest> requests) {
    Iterables.addAll(flushQueue, requests);
    executor.execute(new FlushTask());
}

From source file:org.yakindu.sct.model.sgraph.naming.SGraphNameProvider.java

public QualifiedName qualifiedName(Synchronization ele) {

    QualifiedName qualifiedNameFromConverter = null;

    if (!Strings.isEmpty(ele.getName())) {
        qualifiedNameFromConverter = QualifiedName.create(ele.getName());
    } else {// w w w .j a  v a  2s  .c  o  m
        LinkedList<Synchronization> list = new LinkedList<Synchronization>();
        Iterables.addAll(list,
                Iterables.filter(((Region) ele.eContainer()).getVertices(), Synchronization.class));
        qualifiedNameFromConverter = QualifiedName.create(_SYNC_NAME + list.indexOf(ele));
    }

    return getParentQualifiedName(ele, qualifiedNameFromConverter);
}

From source file:com.zimbra.soap.mail.type.CalendarReply.java

public static List<CalendarReplyInterface> toInterfaces(Iterable<CalendarReply> params) {
    if (params == null)
        return null;
    List<CalendarReplyInterface> newList = Lists.newArrayList();
    Iterables.addAll(newList, params);
    return newList;
}

From source file:com.zimbra.soap.voice.type.ResetPhoneVoiceFeaturesSpec.java

public void setCallFeatures(Iterable<PhoneVoiceFeaturesSpec.CallFeatureReq> callFeatures) {
    this.callFeatures.clear();
    if (callFeatures != null) {
        Iterables.addAll(this.callFeatures, callFeatures);
    }//from  w w w. j  a  v a  2 s .c om
}

From source file:org.apache.druid.segment.IndexBuilder.java

public IndexBuilder rows(Iterable<InputRow> rows) {
    this.rows.clear();
    Iterables.addAll(this.rows, rows);
    return this;
}