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

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

Introduction

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

Prototype

@Deprecated
public static <E> Iterable<E> unmodifiableIterable(ImmutableCollection<E> iterable) 

Source Link

Document

Simply returns its argument.

Usage

From source file:de.cosmocode.palava.core.DefaultRegistry.java

@Override
public <T> Iterable<T> getListeners(Key<T> key) {
    Preconditions.checkNotNull(key, "Key");
    @SuppressWarnings("unchecked")
    final Iterable<T> listeners = (Iterable<T>) mapping.get(key);
    return Iterables.unmodifiableIterable(listeners);
}

From source file:org.apache.druid.query.GroupByMergedQueryRunner.java

public GroupByMergedQueryRunner(ExecutorService exec, Supplier<GroupByQueryConfig> configSupplier,
        QueryWatcher queryWatcher, NonBlockingPool<ByteBuffer> bufferPool,
        Iterable<QueryRunner<T>> queryables) {
    this.exec = MoreExecutors.listeningDecorator(exec);
    this.queryWatcher = queryWatcher;
    this.queryables = Iterables.unmodifiableIterable(Iterables.filter(queryables, Predicates.notNull()));
    this.configSupplier = configSupplier;
    this.bufferPool = bufferPool;
}

From source file:eu.interedition.collatex.util.ParallelSegmentationApparatus.java

public static void generate(VariantGraphRanking ranking, GeneratorCallback callback) {

    callback.start();//from   w w w  . j  ava2  s  . co  m

    final Set<Witness> allWitnesses = ranking.witnesses();
    for (Iterator<Map.Entry<Integer, Collection<VariantGraph.Vertex>>> rowIt = ranking.getByRank().asMap()
            .entrySet().iterator(); rowIt.hasNext();) {
        final Map.Entry<Integer, Collection<VariantGraph.Vertex>> row = rowIt.next();
        final int rank = row.getKey();
        final Collection<VariantGraph.Vertex> vertices = row.getValue();

        if (vertices.size() == 1 && Iterables.getOnlyElement(vertices).tokens().isEmpty()) {
            // skip start and end vertex
            continue;
        }

        // spreading vertices with same rank according to their registered transpositions
        final Multimap<Integer, VariantGraph.Vertex> verticesByTranspositionRank = HashMultimap.create();
        for (VariantGraph.Vertex v : vertices) {
            int transpositionRank = 0;
            for (VariantGraph.Transposition transposition : v.transpositions()) {
                for (VariantGraph.Vertex tv : transposition) {
                    transpositionRank += (ranking.apply(tv).intValue() - rank);
                }
            }
            verticesByTranspositionRank.put(transpositionRank, v);
        }

        // render segments
        for (Iterator<Integer> transpositionRankIt = Ordering.natural()
                .immutableSortedCopy(verticesByTranspositionRank.keySet()).iterator(); transpositionRankIt
                        .hasNext();) {
            final Multimap<Witness, Token> tokensByWitness = HashMultimap.create();
            for (VariantGraph.Vertex v : verticesByTranspositionRank.get(transpositionRankIt.next())) {
                for (Token token : v.tokens()) {
                    tokensByWitness.put(token.getWitness(), token);
                }
            }

            final SortedMap<Witness, Iterable<Token>> cellContents = Maps.newTreeMap(Witness.SIGIL_COMPARATOR);
            for (Witness witness : allWitnesses) {
                cellContents.put(witness,
                        tokensByWitness.containsKey(witness)
                                ? Iterables.unmodifiableIterable(tokensByWitness.get(witness))
                                : Collections.<Token>emptySet());
            }

            callback.segment(cellContents);
        }
    }

    callback.end();
}

From source file:fr.putnami.pwt.core.widget.client.TableBody.java

public Iterable<TableRow<T>> getRows() {
    return Iterables.unmodifiableIterable(this.rows);
}

From source file:chess_.engine.classic.board.Board.java

public Iterable<Piece> getAllPieces() {
    return Iterables.unmodifiableIterable(Iterables.concat(this.whitePieces, this.blackPieces));
}

From source file:edu.oregonstate.eecs.mcplan.search.pats.PatsStateNode.java

public Iterable<PatsActionNode<S, A>> successors() {
    return Iterables.unmodifiableIterable(successors.values());
}

From source file:fr.putnami.pwt.core.model.client.visitor.FlusherVisitor.java

public Iterable<Error> getErrors() {
    return Iterables.unmodifiableIterable(this.errors.values());
}

From source file:org.polarsys.reqcycle.traceability.engine.Request.java

public Iterable<Couple> getCouples() {
    return Iterables.unmodifiableIterable(elements);
}

From source file:chess_.engine.classic.board.Board.java

public Iterable<Move> getAllLegalMoves() {
    return Iterables.unmodifiableIterable(
            Iterables.concat(this.whitePlayer.getLegalMoves(), this.blackPlayer.getLegalMoves()));
}

From source file:io.druid.query.ChainedExecutionQueryRunner.java

public ChainedExecutionQueryRunner(ExecutorService exec, Ordering<T> ordering, QueryWatcher queryWatcher,
        Iterable<QueryRunner<T>> queryables) {
    // listeningDecorator will leave PrioritizedExecutorService unchanged,
    // since it already implements ListeningExecutorService
    this.exec = MoreExecutors.listeningDecorator(exec);
    this.ordering = ordering;
    this.queryables = Iterables.unmodifiableIterable(queryables);
    this.queryWatcher = queryWatcher;
}