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

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

Introduction

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

Prototype

static <T> T[] toArray(Iterable<? extends T> iterable, T[] array) 

Source Link

Usage

From source file:co.signal.loadgen.LoadGeneratorBeanInfo.java

public LoadGeneratorBeanInfo() {
    super(LoadGenerator.class);

    createPropertyGroup("load_generator", new String[] { CLASS_NAME, FILENAME, VARIABLE_NAME });

    List<String> classes = findAvailableImplementations();
    PropertyDescriptor p = property(CLASS_NAME);
    p.setValue(NOT_UNDEFINED, Boolean.TRUE);
    p.setValue(DEFAULT, classes.get(0));
    p.setValue(NOT_EXPRESSION, Boolean.TRUE);
    p.setValue(NOT_OTHER, Boolean.TRUE);
    p.setValue(TAGS, Iterables.toArray(classes, String.class));

    p = property(FILENAME);/* w  ww.  jav  a2  s . c o  m*/
    p.setValue(NOT_UNDEFINED, Boolean.TRUE);
    p.setValue(DEFAULT, "");
    p.setValue(NOT_EXPRESSION, Boolean.TRUE);

    p = property(VARIABLE_NAME);
    p.setValue(NOT_UNDEFINED, Boolean.TRUE);
    p.setValue(DEFAULT, "");
    p.setValue(NOT_EXPRESSION, Boolean.TRUE);
}

From source file:org.matsim.contrib.taxi.optimizer.mip.MIPRequestData.java

MIPRequestData(TaxiOptimizerContext optimContext, SortedSet<TaxiRequest> unplannedRequests,
        int planningHorizon) {
    dimension = Math.min(planningHorizon, unplannedRequests.size());

    requests = Iterables.toArray(Iterables.limit(unplannedRequests, dimension), TaxiRequest.class);

    for (int i = 0; i < dimension; i++) {
        reqIdToIdx.put(requests[i].getId(), i);
    }/* www.  j ava  2  s. c o m*/
}

From source file:playground.michalm.taxi.optimizer.mip.MIPRequestData.java

MIPRequestData(TaxiOptimizerConfiguration optimConfig, SortedSet<TaxiRequest> unplannedRequests,
        int planningHorizon) {
    dimension = Math.min(planningHorizon, unplannedRequests.size());

    requests = Iterables.toArray(Iterables.limit(unplannedRequests, dimension), TaxiRequest.class);

    for (int i = 0; i < dimension; i++) {
        reqIdToIdx.put(requests[i].getId(), i);
    }//  w  ww .  j  a v  a2  s  .  c om
}

From source file:org.opentestsystem.shared.monitoringalerting.service.impl.DiscreteIntakeServiceImpl.java

@Override
public String[] getDistinctComponents() {
    return Iterables.toArray(
            Lists.transform(this.discreteIntakeRepository.findByType(TYPE.COMPONENT), VALUE_TRANSFORMER),
            String.class);
}

From source file:ninja.leaping.permissionsex.bukkit.PEXVault.java

@Override
public String[] getGroups() {
    return Iterables.toArray(this.plugin.getGroupSubjects().getAllIdentifiers(), String.class);
}

From source file:com.cloudera.director.google.compute.util.ComputeUrls.java

public static String buildGlobalUrl(String projectId, String... resourcePathParts) {
    List<String> pathParts = Lists.newArrayList("global");

    if (resourcePathParts != null) {
        pathParts.addAll(Lists.newArrayList(resourcePathParts));
    }//from   w w  w.j av a2  s  . c o m

    return buildGoogleComputeApisUrl(projectId, Iterables.toArray(pathParts, String.class));
}

From source file:org.isisaddons.module.quartz.dom.jobs.RunBackgroundCommandsJob.java

AuthenticationSession newAuthSession(JobExecutionContext context) {
    String user = getKey(context, "user");
    String rolesStr = getKey(context, "roles");
    String[] roles = Iterables.toArray(Splitter.on(",").split(rolesStr), String.class);
    return new SimpleSession(user, roles);
}

From source file:org.eclipse.xtext.ui.editor.outline.impl.OutlineFilterAndSorter.java

public IOutlineNode[] filterAndSort(Iterable<IOutlineNode> nodes) {
    final Iterable<IFilter> enabledFilters = getEnabledFilters();
    Iterable<IOutlineNode> filteredNodes = null;
    if (Iterables.isEmpty(enabledFilters)) {
        filteredNodes = nodes;/*from   w ww  . ja  va  2  s  . c  o m*/
    } else {
        filteredNodes = Iterables.filter(nodes, new Predicate<IOutlineNode>() {
            @Override
            public boolean apply(final IOutlineNode node) {
                return Iterables.all(enabledFilters, new Predicate<IFilter>() {
                    @Override
                    public boolean apply(IFilter filter) {
                        return filter.apply(node);
                    }
                });
            }
        });
    }
    IOutlineNode[] nodesAsArray = Iterables.toArray(filteredNodes, IOutlineNode.class);
    if (comparator != null && isSortingEnabled())
        Arrays.sort(nodesAsArray, comparator);
    return nodesAsArray;
}

From source file:com.reprezen.swagedit.editor.outline.OutlineContentProvider.java

@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof AbstractNode) {
        return Iterables.toArray(((AbstractNode) parentElement).elements(), AbstractNode.class);
    }//from   w  ww  .  j av a 2 s .co m
    return null;
}

From source file:com.pingcap.tikv.util.TiFluentIterable.java

public final E[] toArray(Class<E> type) {
    return Iterables.toArray(iter, type);
}