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

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

Introduction

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

Prototype

public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) 

Source Link

Document

Combines two iterables into a single iterable.

Usage

From source file:org.dslforge.xtext.common.scoping.BasicTextMultimapBasedScope.java

/**
 * Workaround! List of uris, take the last segment which is the name of the file,
 * concatenate with name and select concatenations which are equals to name
 *///from  w  w  w.  j  a va2 s.  com
@Override
protected Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
    Iterable<IEObjectDescription> objectDescriptions = Collections.emptyList();
    String[] segments = (String[]) name.getSegments().toArray();
    List<String> asList = Arrays.asList(segments);
    List<String> modifiableList = Lists.newArrayList();
    modifiableList.addAll(asList);

    for (URI uri : availableResourceURs) {
        String fileName = uri.lastSegment();
        String root = fileName.substring(0, fileName.indexOf("."));
        if (root != null) {
            modifiableList.add(0, root);
        }
        QualifiedName query = QualifiedName.create(modifiableList);
        if (isIgnoreCase()) {
            query = name.toLowerCase();
        }
        if (elements.containsKey(query)) {
            Collection<IEObjectDescription> result = elements.get(query);
            objectDescriptions = Iterables.concat(objectDescriptions, result);
        }
    }
    objectDescriptions = getDefaultLocalElementsByName(name);
    objectDescriptions = Iterables.concat(objectDescriptions, super.getLocalElementsByName(name));
    return objectDescriptions;
}

From source file:org.apache.cassandra.schema.KeyspaceMetadata.java

public Iterable<CFMetaData> tablesAndViews() {
    return Iterables.concat(tables, views.metadatas());
}

From source file:org.summer.dsl.model.ui.notification.LayeredTypeResourceDescription.java

public Iterable<IEObjectDescription> getExportedObjectsByObject(final EObject object) {
    final URI uri = EcoreUtil2.getPlatformResourceOrNormalizedURI(object);
    Iterable<IEObjectDescription> additionallyFiltered = Iterables.filter(getExportedObjects(),
            new Predicate<IEObjectDescription>() {
                public boolean apply(IEObjectDescription input) {
                    if (input.getEObjectOrProxy() == object)
                        return true;
                    if (uri.equals(input.getEObjectURI())) {
                        return true;
                    }/*from w  w w  .  j a va2s.c o  m*/
                    return false;
                }
            });
    return Iterables.concat(delegate.getExportedObjectsByObject(object), additionallyFiltered);
}

From source file:org.eclipse.elk.alg.mrtree.intermediate.LevelHeightProcessor.java

/**
 * Set the height property for each node in the current level and for their children. The height
 * is the height of the tallest node in the level.
 * /* ww w  .  ja  v a  2s  .  c om*/
 * @param currentLevel
 *            the list of TNode at the same level, for which the neighbors and siblings should
 *            be determined
 * @param progressMonitor
 *            the current progress monitor
 */
private void setNeighbors(final Iterable<TNode> currentLevel, final IElkProgressMonitor progressMonitor) {
    /** only do something in filled levels */
    if (!Iterables.isEmpty(currentLevel)) {
        /** create subtask for recursive descent */
        IElkProgressMonitor sT = progressMonitor.subTask(Iterables.size(currentLevel) / numberOfNodes);

        sT.begin("Set neighbors in level", 1f);

        /** build empty iterator */
        Iterable<TNode> nextLevel = new Iterable<TNode>() {

            public Iterator<TNode> iterator() {
                return Iterators.emptyIterator();
            }
        };

        double height = 0d;

        for (TNode cN : currentLevel) {
            /** append the children of the current node to the next level */
            nextLevel = Iterables.concat(nextLevel, cN.getChildren());
            /** check if the node is the tallest node so far */
            if (height < cN.getSize().y) {
                height = cN.getSize().y;
            }
        }
        for (TNode cN : currentLevel) {
            /** set the level height for the node */
            cN.setProperty(InternalProperties.LEVELHEIGHT, height);
        }

        /** add amount of work units to the whole task */
        sT.done();

        /** determine neighbors by bfs and for the whole graph */
        setNeighbors(nextLevel, progressMonitor);
    }

}

From source file:org.richfaces.cdk.resource.writer.impl.ResourceWriterImpl.java

public ResourceWriterImpl(File resourceContentsDir, Iterable<ResourceProcessor> resourceProcessors, Log log,
        Set<ResourceKey> resourcesWithKnownOrder) {
    this.resourceContentsDir = resourceContentsDir;
    this.resourceProcessors = Iterables.concat(resourceProcessors,
            Collections.singleton(ThroughputResourceProcessor.INSTANCE));
    this.log = log;
    this.resourcesWithKnownOrder = resourcesWithKnownOrder;

    resourceContentsDir.mkdirs();/*  www.  j ava  2  s  . co m*/

    currentTime = System.currentTimeMillis();
}