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(final Iterable<? extends Iterable<? extends T>> inputs) 

Source Link

Document

Combines multiple iterables into a single iterable.

Usage

From source file:com.facebook.buck.rules.coercer.ListConcatenatingCoercer.java

@Override
public Object concat(Iterable<Object> elements) {
    Iterable<List<Object>> lists = Iterables.transform(elements, List.class::cast);
    return ImmutableList.copyOf(Iterables.concat(lists));
}

From source file:eu.eidas.auth.commons.attribute.AttributeRegistries.java

/**
 * Copies an attribute registry in memory from another existing AttributeRegistry.
 *
 * @param attributeRegistry the attribute registry to copy.
 *//*  ww  w.ja  va 2  s . c  om*/
@Nonnull
public static AttributeRegistry copyOf(@Nonnull AttributeRegistry attributeRegistry,
        @Nullable AttributeRegistry... otherRegistries) {
    Preconditions.checkNotNull(attributeRegistry, "attributeRegistry");
    if (null == otherRegistries || otherRegistries.length <= 0) {
        return of(attributeRegistry.getAttributes());
    }
    ImmutableSortedSet<AttributeDefinition<?>>[] definitions = new ImmutableSortedSet[otherRegistries.length
            + 1];
    definitions[0] = attributeRegistry.getAttributes();
    for (int i = 0; i < otherRegistries.length; i++) {
        definitions[i + 1] = otherRegistries[i].getAttributes();
    }
    return of(Iterables.concat(definitions));
}

From source file:com.twitter.aurora.scheduler.filter.AttributeFilter.java

/**
 * Tests whether a constraint is satisfied by attributes.
 *
 * @param attributes Host attributes./*w w  w  .  j  av a 2  s . c o  m*/
 * @param constraint Constraint to match.
 * @return {@code true} if the attribute satisfies the constraint, {@code false} otherwise.
 */
static boolean matches(Set<Attribute> attributes, IValueConstraint constraint) {
    Set<String> allAttributes = ImmutableSet
            .copyOf(Iterables.concat(Iterables.transform(attributes, GET_VALUES)));
    boolean match = Iterables.any(constraint.getValues(), Predicates.in(allAttributes));
    return constraint.isNegated() ^ match;
}

From source file:msi.gaml.expressions.IExpressionCompiler.java

public static Iterable<? extends OperatorProto> getAllOperators() {
    return Iterables.concat(Iterables.transform(OPERATORS.values(), (each) -> each.values()));
}

From source file:org.springframework.ide.eclipse.boot.wizard.importing.ImportStrategies.java

public static Iterable<ImportStrategy> all() {
    @SuppressWarnings("unchecked")
    Iterable<ImportStrategy>[] perBuildType = new Iterable[BuildType.values().length];
    int i = 0;/*from w  ww . j a  va2s . c o  m*/
    for (BuildType bt : BuildType.values()) {
        perBuildType[i++] = bt.getImportStrategies();
    }
    return Iterables.concat(perBuildType);
}

From source file:org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.LeafSetNodeBaseSerializer.java

@Override
public final Iterable<E> serialize(final LeafListSchemaNode schema, final LeafSetNode<?> node) {
    return Iterables.concat(Iterables.transform(node.getValue(), input -> {
        final Iterable<E> serializedChild = getLeafSetEntryNodeSerializer().serialize(schema, input);
        final int size = Iterables.size(serializedChild);
        Preconditions.checkState(size == 1,
                "Unexpected count of elements for leaf-list entry serialized from: %s, should be 1, was: %s",
                input, size);/*www .ja v  a 2  s  . c  o  m*/
        return serializedChild;
    }));
}

From source file:org.onos.yangtools.yang.data.impl.schema.transform.base.serializer.LeafSetNodeBaseSerializer.java

@Override
public final Iterable<E> serialize(final LeafListSchemaNode schema, final LeafSetNode<?> node) {
    return Iterables
            .concat(Iterables.transform(node.getValue(), new Function<LeafSetEntryNode<?>, Iterable<E>>() {
                @Override//from  ww  w  .j a v  a2  s  .  c o  m
                public Iterable<E> apply(final LeafSetEntryNode<?> input) {
                    final Iterable<E> serializedChild = getLeafSetEntryNodeSerializer().serialize(schema,
                            input);
                    final int size = Iterables.size(serializedChild);
                    Preconditions.checkState(size == 1,
                            "Unexpected count of elements for leaf-list entry serialized from: %s, should be 1, was: %s",
                            input, size);
                    return serializedChild;
                }
            }));
}

From source file:io.druid.server.http.InventoryViewUtils.java

public static Set<DruidDataSource> getDataSources(InventoryView serverInventoryView) {
    TreeSet<DruidDataSource> dataSources = Sets.newTreeSet(new Comparator<DruidDataSource>() {
        @Override//  w  ww  .  j  a  va 2s .  c om
        public int compare(DruidDataSource druidDataSource, DruidDataSource druidDataSource1) {
            return druidDataSource.getName().compareTo(druidDataSource1.getName());
        }
    });
    dataSources
            .addAll(Lists.newArrayList(Iterables.concat(Iterables.transform(serverInventoryView.getInventory(),
                    new Function<DruidServer, Iterable<DruidDataSource>>() {
                        @Override
                        public Iterable<DruidDataSource> apply(DruidServer input) {
                            return input.getDataSources();
                        }
                    }))));
    return dataSources;
}

From source file:com.analog.lyric.benchmarking.utils.doublespace.SequenceIndexer.java

public SequenceIndexer(Indexer... indexers) {
    _indexers = Arrays.asList(indexers);
    _iterable = Iterables.concat(indexers);
}

From source file:com.facebook.buck.rules.coercer.MapConcatenatingCoercer.java

@Override
public Object concat(Iterable<Object> elements) {
    @SuppressWarnings("unchecked")
    Iterable<Set<Entry<Object, Object>>> maps = Iterables.transform(elements,
            map -> ((Map<Object, Object>) map).entrySet());
    return ImmutableMap.copyOf(Iterables.concat(maps));
}