List of usage examples for com.google.common.collect Iterables transform
@CheckReturnValue public static <F, T> Iterable<T> transform(final Iterable<F> fromIterable, final Function<? super F, ? extends T> function)
From source file:cosmos.sql.call.ChildVisitor.java
public Iterable<?> visit(final Function<ChildVisitor, Iterable<?>> callbackFunction, final Predicate<ChildVisitor> childFilter) { Collection<ChildVisitor> equalities = children.values(); return Iterables.concat(Iterables.transform(Iterables.filter(equalities, childFilter), callbackFunction)); }
From source file:org.polarsys.reqcycle.traceability.cache.emfbased.functions.TraceabilityLink2Link.java
@Override public Link apply(TraceabilityLink aLink) { TraceableElement2Traceable traceableElement2Traceable = new TraceableElement2Traceable(); ZigguratInject.inject(traceableElement2Traceable); Iterable<Reachable> sources = Iterables.transform(aLink.getSources(), traceableElement2Traceable); Iterable<Reachable> targets = Iterables.transform(aLink.getTargets(), traceableElement2Traceable); // RFa provide ID - to check // FIXME/* ww w .j a va2 s .com*/ UUID uniqueID = UUID.randomUUID(); URI uri = null; try { uri = new URI(aLink.getResource().getUri()); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } Reachable r = creator.getReachable(uri); Link link = new Link(r, new TType(uniqueID.toString(), aLink.getLabel()), sources, targets); return link; }
From source file:com.isotrol.impe3.hib.query.PageSupport.java
/** * Page support for criteria queries.// w w w. jav a 2 s. co m * @param <E> Query output type. * @param <D> DTO type. * @param count Count criteria (optional). * @param select Selection criteria (required). * @param pag Pagination (optional). * @param transformer Transformer (required). * @return */ public static <E, D> PageDTO<D> getPage(Criteria count, Criteria select, PaginationDTO pag, Function<? super E, ? extends D> transformer) { checkNotNull(select, "A selection query must be provided"); final PageDTO<D> page = new PageDTO<D>(); if (count != null) { count.setProjection(Projections.rowCount()); page.setTotal(((Number) count.uniqueResult()).intValue()); } if (pag != null) { page.setFirst(pag.getFirst()); page.setSize(pag.getSize()); select.setFirstResult(pag.getFirst()); select.setMaxResults(pag.getSize()); } @SuppressWarnings("unchecked") final List<E> list = select.list(); page.setElements(Lists.newArrayList(Iterables.transform(list, transformer))); return page; }
From source file:com.facebook.presto.serde.DictionaryEncoder.java
@Override public Encoder append(Iterable<Tuple> tuples) { checkNotNull(tuples, "tuples is null"); checkState(!finished, "already finished"); Iterable<Tuple> idTuples = Iterables.transform(tuples, new Function<Tuple, Tuple>() { @Override//from w w w . j a va 2s .c o m public Tuple apply(Tuple tuple) { if (tupleInfo == null) { tupleInfo = tuple.getTupleInfo(); dictionaryBuilder = new DictionaryBuilder(tupleInfo); } long id = dictionaryBuilder.getId(tuple); return createTuple(id); } }); idWriter.append(idTuples); return this; }
From source file:org.vclipse.dependency.scoping.DependencyScopeProvider.java
IScope scope_Function_characteristics(org.vclipse.vcml.vcml.Function context, EReference ref) { VariantFunction vf = context.getFunction(); return Scopes.scopeFor( Iterables.transform(vf.getArguments(), new Function<VariantFunctionArgument, Characteristic>() { public Characteristic apply(VariantFunctionArgument object) { return object.getCharacteristic(); }//from w w w . ja v a2 s . c o m })); }
From source file:io.druid.timeline.UnionTimeLineLookup.java
@Override public Iterable<TimelineObjectHolder<VersionType, ObjectType>> lookup(final Interval interval) { return Iterables.mergeSorted(Iterables.transform(delegates, new Function<TimelineLookup<VersionType, ObjectType>, Iterable<TimelineObjectHolder<VersionType, ObjectType>>>() { @Override/*from w w w . jav a2 s. c o m*/ public Iterable<TimelineObjectHolder<VersionType, ObjectType>> apply( TimelineLookup<VersionType, ObjectType> input) { return input.lookup(interval); } }), new Comparator<TimelineObjectHolder<VersionType, ObjectType>>() { @Override public int compare(TimelineObjectHolder<VersionType, ObjectType> o1, TimelineObjectHolder<VersionType, ObjectType> o2) { return Comparators.intervalsByStartThenEnd().compare(o1.getInterval(), o2.getInterval()); } }); }
From source file:com.facebook.presto.server.PluginClassLoader.java
public PluginClassLoader(List<URL> urls, ClassLoader parent, Iterable<String> hiddenClasses, Iterable<String> parentFirstClasses) { this(urls, parent, hiddenClasses, parentFirstClasses, Iterables.transform(hiddenClasses, PluginClassLoader::classNameToResource), Iterables.transform(parentFirstClasses, PluginClassLoader::classNameToResource)); }
From source file:com.facebook.buck.core.parser.buildtargetparser.FlavorParser.java
/** * Given a comma-separated string of flavors, returns an iterable containing the separated names * of the flavors inside.//from www . ja v a 2s. c o m * * <p>Also maps deprecated flavor names to their supported names. */ public Iterable<String> parseFlavorString(String flavorString) { return Iterables.transform(Splitter.on(",").omitEmptyStrings().trimResults().split(flavorString), flavor -> { String mapped = DEPRECATED_FLAVORS.get(flavor); if (mapped != null) { // Show a warning the first time a deprecated flavor is used. if (deprecatedFlavorWarningShown.add(flavor)) { LOG.warn("Flavor %s is deprecated; use %s instead.", flavor, mapped); } return mapped; } else { return flavor; } }); }
From source file:playground.michalm.taxi.schedule.TaxiSchedules.java
public static Iterable<TaxiRequest> getTaxiRequests(Schedule<TaxiTask> schedule) { Iterable<TaxiTask> pickupTasks = Iterables.filter(schedule.getTasks(), IS_PICKUP); return Iterables.transform(pickupTasks, TAXI_TASK_TO_REQUEST); }
From source file:com.facebook.buck.cxx.platform.WindowsPreprocessor.java
@Override public Iterable<String> localIncludeArgs(Iterable<String> includeRoots) { return Iterables.transform(includeRoots, prependIncludeFlag); }