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:com.atlassian.jira.rest.client.domain.EntityHelper.java
public static Iterable<String> toNamesList(Iterable<? extends NamedEntity> items) { return Iterables.transform(items, new Function<NamedEntity, String>() { @Override//from ww w .jav a2 s. com public String apply(NamedEntity from) { return from.getName(); } }); }
From source file:org.apache.druid.indexer.path.HadoopGlobPathSplitter.java
/** * Splits given hadoop glob path by commas. * e.g. splitGlob("/a,/b") -> ["/a","/b"] * splitGlob("/a/{c,d}") -> ["/a/c", "/a/d"] *//*w ww.j av a 2 s . co m*/ public static Iterable<String> splitGlob(String path) { return Iterables.transform(splitGlob(new CharStream(path)), Functions.toStringFunction()); }
From source file:com.google.gerrit.acceptance.rest.account.AccountAssert.java
public static void assertAccountInfos(List<TestAccount> expected, List<AccountInfo> actual) { Iterable<Account.Id> expectedIds = TestAccount.ids(expected); Iterable<Account.Id> actualIds = Iterables.transform(actual, a -> new Account.Id(a._accountId)); assertThat(actualIds).containsExactlyElementsIn(expectedIds).inOrder(); for (int i = 0; i < expected.size(); i++) { AccountAssert.assertAccountInfo(expected.get(i), actual.get(i)); }/*from w w w . j a v a 2 s. c om*/ }
From source file:org.killbill.billing.invoice.dao.InvoiceModelDaoHelper.java
public static BigDecimal getBalance(final InvoiceModelDao invoiceModelDao) { return InvoiceCalculatorUtils.computeInvoiceBalance(invoiceModelDao.getCurrency(), Iterables .transform(invoiceModelDao.getInvoiceItems(), new Function<InvoiceItemModelDao, InvoiceItem>() { @Override// w w w. java 2 s .c o m public InvoiceItem apply(final InvoiceItemModelDao input) { return InvoiceItemFactory.fromModelDao(input); } }), Iterables.transform(invoiceModelDao.getInvoicePayments(), new Function<InvoicePaymentModelDao, InvoicePayment>() { @Nullable @Override public InvoicePayment apply(final InvoicePaymentModelDao input) { return new DefaultInvoicePayment(input); } }), invoiceModelDao.isMigrated() || invoiceModelDao.isWrittenOff()); }
From source file:org.apache.cassandra.cql3.Terms.java
public static Iterable<Function> getFunctions(Iterable<Term> terms) { if (terms == null) return Collections.emptySet(); return Iterables.concat(Iterables.transform(terms, TO_FUNCTION_ITERABLE)); }
From source file:com.reprezen.kaizen.oasparser.jsonoverlay.coll.CollectionData.java
public static <OV extends JsonOverlay<?>> CollectionData<OV> of(Collection<OV> data) { return new CollectionData<OV>(Iterables.transform(data, new Function<OV, Entry<String, OV>>() { @Override//from w ww. java2s . co m public Entry<String, OV> apply(OV overlay) { return new SimpleEntry<>(overlay.getKey(), overlay); } })); }
From source file:org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry.java
public static <E extends Entry<String, ? extends NodeState>> Iterable<ChildNodeEntry> iterable( Iterable<E> set) {//from www . j a v a 2s .com return Iterables.transform(set, new Function<Entry<String, ? extends NodeState>, ChildNodeEntry>() { @Override public ChildNodeEntry apply(Entry<String, ? extends NodeState> entry) { return new MemoryChildNodeEntry(entry.getKey(), entry.getValue()); } }); }
From source file:see.util.Reduce.java
/** * Apply a function to each element of a collection, and concatenate results. * Operation is lazy - collections won't be queried in process. * * @param initial initial collection//from w w w. j a v a 2 s. co m * @param f function, which from element of initial collection to separate collection * @param <A> initial collection type * @param <B> resulting collection type * @return lazy collection, formed from applying function and concatenating results. */ public static <A, B> Iterable<B> flatMap(Iterable<A> initial, Function<? super A, ? extends Iterable<B>> f) { return Iterables.concat(Iterables.transform(initial, f)); }
From source file:com.google.devtools.build.lib.skyframe.AspectCompletionValue.java
public static Iterable<SkyKey> keys(Collection<AspectValue> targets, final TopLevelArtifactContext ctx) { return Iterables.transform(targets, new Function<AspectValue, SkyKey>() { @Override//from w ww . j av a 2 s.co m public SkyKey apply(AspectValue aspectValue) { return SkyKey.create(SkyFunctions.ASPECT_COMPLETION, AspectCompletionKey.create(aspectValue.getKey(), ctx)); } }); }
From source file:com.facebook.buck.cli.TargetGraphTestParsing.java
public static TargetGraph expandedTargetGraphToIncludeTestsForTargets(ProjectGraphParser parser, TargetGraph original, ImmutableSet<BuildTarget> targets) throws IOException, InterruptedException { ImmutableSet<BuildTarget> explicitTestTargets; explicitTestTargets = TargetGraphAndTargets.getExplicitTestTargets(targets, original, true); Iterable<BuildTarget> targetsWithTests = Sets.union(targets, explicitTestTargets); return parser.buildTargetGraphForTargetNodeSpecs( Iterables.transform(targetsWithTests, BuildTargetSpec.TO_BUILD_TARGET_SPEC)); }