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.yahoo.yqlplus.engine.sources.BatchKeySource.java
@Query public Iterable<Person> lookupAll(@Key("id") List<String> ids) { return Iterables.transform(ids, new Function<String, Person>() { @Nullable//from ww w . j av a 2 s. c om @Override public Person apply(@Nullable String input) { return new Person(input, input, Integer.parseInt(input)); } }); }
From source file:org.apache.isis.core.progmodel.facets.value.datetimejodalocal.JodaLocalDateTimeUtil.java
static LocalDateTime parseDate(final String dateStr, final Localization localization, List<DateTimeFormatter> parseFormatters) { Iterable<DateTimeFormatter> elements = Iterables.transform(parseFormatters, JodaFunctions.withLocale(localization)); return parseDateTime(dateStr, elements); }
From source file:org.apache.kylin.storage.hbase.util.ZookeeperUtil.java
/** * Get zookeeper connection string from HBase Configuration * * @return Zookeeper Connection string/*from w w w . ja v a 2 s. com*/ */ public static String getZKConnectString() { Configuration conf = HBaseConnection.getCurrentHBaseConfiguration(); final String serverList = conf.get(HConstants.ZOOKEEPER_QUORUM); final String port = conf.get(HConstants.ZOOKEEPER_CLIENT_PORT); return StringUtils .join(Iterables.transform(Arrays.asList(serverList.split(",")), new Function<String, String>() { @Nullable @Override public String apply(String input) { return input + ":" + port; } }), ","); }
From source file:org.springframework.social.showcase.signin.SignInUtils.java
public static boolean isSignedIn() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return false; }/*from w w w . j a v a 2 s . c o m*/ Iterable<String> authorities = Iterables.transform(authentication.getAuthorities(), authorityName); return Iterables.contains(authorities, "ROLE_USER"); }
From source file:com.pingcap.tikv.TiConfiguration.java
public static TiConfiguration createDefault(List<String> pdAddrs) { TiConfiguration conf = new TiConfiguration(); conf.pdAddrs = ImmutableList.copyOf(Iterables.transform(ImmutableSet.copyOf(pdAddrs).asList(), addStr -> HostAndPort.fromString(addStr))); return conf;//from w ww .j a v a 2 s. c o m }
From source file:rapture.table.mongodb.IndexNameFactory.java
static String createIndexName(IndexDefinition indexDefinition) { String indexName = indexDefinition.getIndexName(); if (indexName == null) { Iterable<String> names = Iterables.transform(indexDefinition.getFields(), new Function<FieldDefinition, String>() { @Override/*from w w w. j a v a 2 s . com*/ public String apply(FieldDefinition input) { return input.getName(); } }); indexName = StringUtils.join(Lists.newArrayList(names), "") + "_idx"; } return indexName; }
From source file:ua.divas.mob.util.JsonReader.java
public static String encodeParams(final Map<String, String> params) { final String paramsUrl = Joiner.on('&').join(// key1=value1&key2=value2... Iterables.transform(params.entrySet(), new Function<Entry<String, String>, String>() { @Override// ww w .j a v a2 s. com public String apply(final Entry<String, String> input) { try { final StringBuffer buffer = new StringBuffer(); buffer.append(input.getKey());// key=value buffer.append('='); buffer.append(URLEncoder.encode(input.getValue(), "utf-8"));// ? ?? ? ? HTML 4.01 return buffer.toString(); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } } })); return paramsUrl; }
From source file:com.google.cloud.bigtable.grpc.scanner.ReadRowTestUtils.java
static Iterable<Row> extractRowsWithKeys(Iterable<ReadRowsResponse> responses) { return Iterables.transform(responses, ROW_KEY_EXTRACTOR_FUNCTION); }
From source file:com.github.ferstl.maven.pomenforcers.util.CommaSeparatorUtils.java
public static <T> void splitAndAddToCollection(String commaSeparatedItems, Collection<T> collection, Function<String, T> transformer) { Iterable<String> items = COMMA_SPLITTER.split(commaSeparatedItems); // Don't touch the collection if there is nothing to add. if (items.iterator().hasNext()) { collection.clear();/*from w w w . j a v a 2 s. co m*/ } Iterables.addAll(collection, Iterables.transform(items, transformer)); }
From source file:org.apache.mahout.clustering.streaming.tools.IOUtils.java
/** * Converts CentroidWritable values in a sequence file into Centroids lazily. * @param dirIterable the source iterable (comes from a SequenceFileDirIterable). * @return an Iterable<Centroid> with the converted vectors. *//*from ww w. ja va 2 s . c o m*/ public static Iterable<Centroid> getCentroidsFromCentroidWritableIterable( Iterable<CentroidWritable> dirIterable) { return Iterables.transform(dirIterable, new Function<CentroidWritable, Centroid>() { @Override public Centroid apply(CentroidWritable input) { Preconditions.checkNotNull(input); return input.getCentroid().clone(); } }); }