List of usage examples for com.google.common.collect Iterables concat
public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> inputs)
From source file:nl.rug.eco.lucene.EnglishLemmaTokenizer.java
public void start(Reader input) { List<List<HasWord>> tokenized = MaxentTagger.tokenizeText(input); tagged = Iterables.concat(tagger.process(tokenized)).iterator(); }
From source file:com.github.msoliter.iroh.container.resolvers.SubclassResolver.java
@Override public Source resolve(final Field field) { /**/*from w w w .ja v a 2 s. c o m*/ * Find all potential sources by filter on whether or not a source's * type can be assigned to the field's type. */ Iterable<Source> potential = Iterables .concat(Collections2.transform(Collections2.filter(sources.keySet(), new Predicate<Class<?>>() { @Override public boolean apply(Class<?> type) { return field.getType().isAssignableFrom(type); } }), new Function<Class<?>, Collection<Source>>() { @Override public Collection<Source> apply(Class<?> type) { return sources.get(type); } })); /** * If there isn't exactly one source in the set, check if there's * exactly one overriding source available, in case we're unit testing. */ if (Iterables.size(potential) != 1) { Iterable<Source> overriding = Iterables.filter(potential, new Predicate<Source>() { @Override public boolean apply(Source source) { return source.isOverriding(); } }); if (Iterables.size(overriding) != 1) { throw new UnexpectedImplementationCountException(field.getType(), Iterables.transform(potential, new Function<Source, Class<?>>() { @Override public Class<?> apply(Source source) { return source.getType(); } })); } else { return overriding.iterator().next(); } } else { return potential.iterator().next(); } }
From source file:eu.numberfour.n4js.scoping.utils.CompositeScope.java
@Override public Iterable<IEObjectDescription> getAllElements() { return Iterables.concat(Arrays.stream(childScopes).map(currScope -> currScope.getAllElements()) .collect(Collectors.toList())); }
From source file:org.eclipse.qvtd.compiler.internal.scheduler.MergedNode.java
@Override public @NonNull Iterable<TypedElement> getTypedElements() { Iterable<Iterable<TypedElement>> transform = Iterables.transform(simpleNodes, NodeToTypedElementsFunction.INSTANCE); @SuppressWarnings("null") @NonNull//from w ww. j a va 2 s . co m Iterable<TypedElement> concat = Iterables.concat(transform); return concat; }
From source file:org.trancecode.collection.TcIterables.java
public static <T> Iterable<T> getDescendants(final Iterable<T> parentElements, final Function<T, Iterable<T>> getChildFunction) { if (Iterables.isEmpty(parentElements)) { return parentElements; }/*from ww w .j a va 2 s . c o m*/ final Iterable<T> children = Iterables.concat(Iterables.transform(parentElements, getChildFunction)); return Iterables.concat(parentElements, getDescendants(children, getChildFunction)); }
From source file:com.google.cloud.dataflow.sdk.runners.worker.SideInputUtils.java
private static Iterable<Object> readSideInputSources(PipelineOptions options, List<Source> sideInputSources, Observer observer, ExecutionContext executionContext) throws Exception { int numSideInputSources = sideInputSources.size(); if (numSideInputSources == 0) { throw new Exception("expecting at least one side input Source"); } else if (numSideInputSources == 1) { return readSideInputSource(options, sideInputSources.get(0), observer, executionContext); } else {/* w w w . j a v a 2 s .c om*/ List<Iterable<Object>> shards = new ArrayList<>(); for (Source sideInputSource : sideInputSources) { shards.add(readSideInputSource(options, sideInputSource, observer, executionContext)); } return Iterables.concat(shards); } }
From source file:org.apache.lens.server.query.collect.UnioningWaitingQueriesSelector.java
/** * Selects queries eligible by all {@link WaitingQueriesSelectionPolicy} to move them out of waiting state. * * @see WaitingQueriesSelector#selectQueries(FinishedLensQuery, EstimatedImmutableQueryCollection) * * @param finishedQuery/*from w w w . j a v a2 s . c o m*/ * @param waitingQueries * @return */ @Override public Set<QueryContext> selectQueries(final FinishedLensQuery finishedQuery, final EstimatedImmutableQueryCollection waitingQueries) { Set<WaitingQueriesSelectionPolicy> allSelectionPolicies = prepareAllSelectionPolicies(finishedQuery); List<Set<QueryContext>> candiateQueriesSets = getAllCandidateQueriesSets(finishedQuery, waitingQueries, allSelectionPolicies); return Sets.newHashSet(Iterables.concat(candiateQueriesSets)); }
From source file:org.apache.people.mreutegg.mhmp.RenderCommandExecutor.java
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player)) { return false; }//from www. ja v a 2 s. co m Player player = (Player) sender; if (command.getName().equalsIgnoreCase("render")) { if (args.length < 1) { sender.sendMessage("You need to specify a .xyz file."); return false; } Iterable<Coordinate> coordinates; try { List<File> files = Lists.newArrayList(new File(".").listFiles(new PatternFilenameFilter(args[0]))); Iterable<Iterable<Coordinate>> allCoords = transform(files, file -> { try { if (file.getName().endsWith(".asc")) { return ASCReader.fromFile(file); } else { return CoordinateReader.fromFile(file); } } catch (IOException e) { throw new UncheckedIOException(e); } }); coordinates = Iterables.concat(allCoords); } catch (UncheckedIOException e) { plugin.getLogger().warning("File not found " + args[0]); return false; } Vector scale = scaleFromArgs(args); new RenderTask(plugin, player, coordinates, scale).runTaskAsynchronously(plugin); return true; } return false; }
From source file:org.jon.ivmark.graphit.tinkerpop.blueprints.BlueprintsNode.java
@Override public Iterable<Vertex> getVertices(Direction direction, String... labels) { if (labels.length == 1) { return edgesRepo.getNeighbors(nodeId, direction, labels[0]); }// www .j a v a 2 s. c o m List<Iterable<Vertex>> iterables = new ArrayList<Iterable<Vertex>>(); for (String label : getLabels(labels)) { Iterable<Vertex> neighbors = edgesRepo.getNeighbors(nodeId, direction, label); iterables.add(neighbors); } return Iterables.concat(iterables); }
From source file:org.adsync4j.testutils.ldap.EmbeddedLdapServerFactoryBean.java
private Iterable<InputStream> resourceArrayListToInputStreamList(List<Resource[]> ldifs) { return Iterables.concat(Lists.transform(ldifs, new Function<Resource[], List<InputStream>>() { @Override/*from w w w .j a v a 2s. c o m*/ public List<InputStream> apply(Resource[] resources) { return resourceArrayToInputStreamList(resources); } })); }