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:com.googlecode.blaisemath.util.SetSelectionModel.java

/**
 * Adds all to the current selection.//  w  w  w. j a  va2 s  .c om
 * @param g elements to add
 */
public void selectAll(Collection<G> g) {
    checkNotNull(g);
    if (!selected.containsAll(g)) {
        Set<G> old = getSelection();
        Iterables.addAll(selected, g);
        pcs.firePropertyChange(SELECTION_PROPERTY, old, getSelection());
    }
}

From source file:com.google.template.soy.basicfunctions.BasicFunctionsRuntime.java

/**
 * Returns a list of all the keys in the given map. For the JavaSource variant, while the function
 * signature is ? instead of legacy_object_map.
 *//*from  w  ww .ja va 2  s  .c om*/
public static List<SoyValue> keys(SoyValue sv) {
    SoyLegacyObjectMap map = (SoyLegacyObjectMap) sv;
    List<SoyValue> list = new ArrayList<>(map.getItemCnt());
    Iterables.addAll(list, map.getItemKeys());
    return list;
}

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

public Collection<SbacRole> getRoles() {
    Collection<SbacRole> roles = new ArrayList<>();
    for (Collection<SbacRole> sbacRoles : sbacRolesMap.values()) {
        Iterables.addAll(roles, Iterables.filter(sbacRoles,
                RolesAndPermissionsServiceImpl.ROLE_APPLICABLE_TO_COMPONENT_FILTER));
    }/*from   ww w .ja  v  a 2s .  co  m*/
    return roles;
}

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

public void setAttrs(Iterable<ConstraintAttr> attrs) {
    this.attrs.clear();
    if (attrs != null) {
        Iterables.addAll(this.attrs, attrs);
    }/*from w  w w  .  ja  v a 2  s. c  o  m*/
}

From source file:com.continuuity.weave.internal.AbstractWeaveController.java

public AbstractWeaveController(RunId runId, ZKClient zkClient, Iterable<LogHandler> logHandlers) {
    super(runId, zkClient);
    this.logHandlers = new ConcurrentLinkedQueue<LogHandler>();
    this.kafkaClient = new SimpleKafkaClient(ZKClients.namespace(zkClient, "/" + runId.getId() + "/kafka"));
    this.discoveryServiceClient = new ZKDiscoveryService(zkClient);
    Iterables.addAll(this.logHandlers, logHandlers);
    this.logPoller = new LogPollerThread(runId, kafkaClient, logHandlers);
}

From source file:vogar.android.DeviceRuntime.java

@Override
public VmCommandBuilder newVmCommandBuilder(Action action, File workingDirectory) {
    List<String> vmCommand = new ArrayList<String>();
    vmCommand.addAll(run.target.targetProcessPrefix(workingDirectory));
    vmCommand.add(run.getAndroidData());
    Iterables.addAll(vmCommand, run.invokeWith());
    vmCommand.add(run.vmCommand);//from w w  w  . j  av a  2 s .c  o  m

    // If you edit this, see also HostRuntime...
    VmCommandBuilder vmCommandBuilder = new VmCommandBuilder(run.log).vmCommand(vmCommand)
            .vmArgs("-Duser.home=" + run.deviceUserHome).maxLength(1024);
    if (modeId == ModeId.APP_PROCESS) {
        return vmCommandBuilder.vmArgs(action.getUserDir().getPath()).classpathViaProperty(true);
    }

    vmCommandBuilder.vmArgs("-Duser.name=" + run.target.getDeviceUserName()).vmArgs("-Duser.language=en")
            .vmArgs("-Duser.region=US");

    if (modeId == ModeId.DEVICE_ART_KITKAT) {
        // Required for KitKat to select the ART runtime. Default is Dalvik.
        vmCommandBuilder.vmArgs("-XXlib:libart.so");
    }
    if (!run.benchmark) {
        if (modeId == ModeId.DEVICE_DALVIK) {
            // Historically, vogar has turned off these options for Dalvik.
            vmCommandBuilder.vmArgs("-Xverify:none");
            vmCommandBuilder.vmArgs("-Xdexopt:none");
        }
        vmCommandBuilder.vmArgs("-Xcheck:jni");
    }
    // dalvikvm defaults to no limit, but the framework sets the limit at 2000.
    vmCommandBuilder.vmArgs("-Xjnigreflimit:2000");
    return vmCommandBuilder;
}

From source file:org.joda.collect.grid.SparseImmutableGrid.java

/**
 * Restricted constructor.//from   www . j  a  v  a 2 s  .c o m
 */
@SuppressWarnings("unchecked")
SparseImmutableGrid(int rowCount, int columnCount, Iterable<? extends Cell<V>> cells) {
    validateCounts(rowCount, columnCount);
    this.rowCount = rowCount;
    this.columnCount = columnCount;

    Collection<Cell<V>> list;
    if (cells instanceof Collection) {
        list = (Collection<Cell<V>>) cells;
    } else {
        list = new ArrayList<Cell<V>>();
        Iterables.addAll(list, cells);
    }
    int size = list.size();
    this.keys = new long[size];
    this.cells = new Cell[size];
    int i = 0;
    for (Cell<V> cell : list) {
        this.keys[i] = key(cell.getRow(), cell.getColumn());
        this.cells[i] = ImmutableCell.copyOf(cell).validateCounts(rowCount, columnCount);
        i++;
    }
}

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

public void setBackups(Iterable<BackupQueryInfo> backups) {
    this.backups.clear();
    if (backups != null) {
        Iterables.addAll(this.backups, backups);
    }/*www. j a  va 2s .c o m*/
}

From source file:edu.umn.msi.tropix.client.directory.impl.UserIterableImpl.java

public Iterator<GridUser> iterator() {
    final Collection<GridUser> users = new LinkedList<GridUser>();
    final Multimap<String, Person> persons = personSupplier.get();
    for (String institution : persons.keySet()) {
        Iterables.addAll(users,
                Iterables.filter(//from w ww .ja  v a  2s.  c  o m
                        Collections2.transform(persons.get(institution), new PersonFunction(institution)),
                        Predicates.not(Predicates.isNull())));
    }
    for (final GridUser user : users) {
        gridUserMap.put(user.getGridId(), user);
    }
    return users.iterator();
}

From source file:org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils.java

/**
 * Return the analysis modules that are of a given class. The modules will be
 * cast to the requested class. If the trace has children, the childrens modules
 * are also returned.//from   w w  w  . ja v a2 s. com
 *
 * @param trace
 *            The trace for which you want the modules, the children trace modules
 *            are added as well.
 * @param moduleClass
 *            Returned modules must extend this class
 * @return List of modules of class moduleClass
 */
public static <T> Iterable<@NonNull T> getAnalysisModulesOfClass(ITmfTrace trace, Class<T> moduleClass) {
    Iterable<IAnalysisModule> analysisModules = trace.getAnalysisModules();
    List<@NonNull T> modules = new ArrayList<>();
    for (IAnalysisModule module : analysisModules) {
        if (moduleClass.isAssignableFrom(module.getClass())) {
            modules.add(checkNotNull(moduleClass.cast(module)));
        }
    }
    for (ITmfEventProvider child : trace.getChildren()) {
        if (child instanceof ITmfTrace) {
            ITmfTrace childTrace = (ITmfTrace) child;
            Iterables.addAll(modules, getAnalysisModulesOfClass(childTrace, moduleClass));
        }
    }
    return modules;
}