List of usage examples for com.google.common.collect Lists transform
@CheckReturnValue public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function)
From source file:com.dangdang.ddframe.rdb.sharding.router.single.SingleRoutingDataSource.java
Set<String> getLogicTables() { Set<String> result = new HashSet<>(routingTableFactors.size()); result.addAll(Lists.transform(routingTableFactors, new Function<SingleRoutingTableFactor, String>() { @Override// w w w .j a v a2 s .c o m public String apply(final SingleRoutingTableFactor input) { return input.getLogicTable(); } })); return result; }
From source file:ratpack.groovy.internal.ClosureInvoker.java
private static List<TypeToken<?>> retrieveParameterTypes(Closure<?> closure) { Class<?>[] parameterTypes = closure.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(Object.class)) { return Collections.emptyList(); } else {//www .ja v a 2s . c o m for (Class<?> clazz : parameterTypes) { if (clazz.isArray()) { throw new IllegalStateException("Closure parameters cannot be array types (type: " + clazz.getName() + ", closure: " + closure.getClass().getName() + ")"); } } return Lists.transform(ImmutableList.copyOf(parameterTypes), new Function<Class<?>, TypeToken<?>>() { @Override public TypeToken<?> apply(Class<?> input) { return TypeToken.of(input); } }); } }
From source file:org.geogig.geoserver.rest.RepositoryListResource.java
@Override public Variant getPreferredVariant() { Optional<Variant> byExtension = Variants.getVariantByExtension(getRequest(), getVariants()); if (byExtension.isPresent()) { return byExtension.get(); }/*from w w w . j a v a 2 s . co m*/ List<MediaType> acceptedMediaTypes = Lists.transform(getRequest().getClientInfo().getAcceptedMediaTypes(), new Function<Preference<MediaType>, MediaType>() { @Override public MediaType apply(Preference<MediaType> input) { return input.getMetadata(); } }); if (acceptedMediaTypes.contains(MediaType.TEXT_HTML)) { return HTML; } if (acceptedMediaTypes.contains(MediaType.TEXT_XML)) { return XML; } if (acceptedMediaTypes.contains(MediaType.APPLICATION_JSON)) { return JSON; } return XML; }
From source file:co.cask.cdap.data2.datafabric.dataset.service.ConversionHelpers.java
static List<? extends Id> strings2ProgramIds(List<String> strings) throws BadRequestException { try {// ww w . j a v a 2 s. com return Lists.transform(strings, new Function<String, Id>() { @Nullable @Override public Id apply(@Nullable String input) { if (input == null || input.isEmpty()) { return null; } return Id.fromString(input, Id.Program.class); } }); } catch (IllegalArgumentException | NullPointerException e) { throw new BadRequestException(e.getMessage()); } }
From source file:ru.org.linux.user.UserLogPrepareService.java
@Nonnull public List<PreparedUserLogItem> prepare(@Nonnull List<UserLogItem> items) { return ImmutableList.copyOf(Lists.transform(items, new Function<UserLogItem, PreparedUserLogItem>() { @Override//from w w w . j a v a2 s . co m public PreparedUserLogItem apply(UserLogItem item) { Map<String, String> options = new HashMap<>(); for (Map.Entry<String, String> option : item.getOptions().entrySet()) { String key = OPTION_DESCRIPTION.get(option.getKey()); if (key == null) { key = escapeHtml(option.getKey()); } String value; switch (option.getKey()) { case UserLogDao.OPTION_OLD_USERPIC: case UserLogDao.OPTION_NEW_USERPIC: value = "<a href=\"/photos/" + escapeHtml(option.getValue()) + "\">" + escapeHtml(option.getValue()) + "</a>"; break; case UserLogDao.OPTION_IP: value = "<a href=\"/sameip.jsp?ip=" + escapeHtml(option.getValue()) + "\">" + escapeHtml(option.getValue()) + "</a>"; break; default: value = escapeHtml(option.getValue()); break; } options.put(key, value); } return new PreparedUserLogItem(item, userDao.getUserCached(item.getActionUser()), options); } })); }
From source file:fr.ybonnel.breizhcamppdf.DataService.java
public List<String> getDates() { return Lists.transform(getProgramme().getJours(), new Function<Jour, String>() { @Override/* ww w.j a v a 2s . c om*/ public String apply(Jour input) { return input.getDate(); } }); }
From source file:com.metamx.druid.index.v1.SpatialDimensionRowFormatter.java
public SpatialDimensionRowFormatter(List<SpatialDimensionSchema> spatialDimensions) { this.spatialDimensions = spatialDimensions; this.spatialDimNames = Sets .newHashSet(Lists.transform(spatialDimensions, new Function<SpatialDimensionSchema, String>() { @Override/*w w w . ja v a 2 s .c om*/ public String apply(SpatialDimensionSchema input) { return input.getDimName(); } })); this.spatialPartialDimNames = Sets.newHashSet(Iterables .concat(Lists.transform(spatialDimensions, new Function<SpatialDimensionSchema, List<String>>() { @Override public List<String> apply(SpatialDimensionSchema input) { return input.getDims(); } }))); }
From source file:com.cloudera.science.ml.client.params.CentersParameters.java
public List<Centers> getCenters() throws IOException { List<MLCenters> centers = AvroIO.read(MLCenters.class, new File(centersFile)); if (!centerIds.isEmpty()) { List<MLCenters> filter = Lists.newArrayListWithExpectedSize(centerIds.size()); for (Integer centerId : centerIds) { filter.add(centers.get(centerId)); }/*from w w w .j a va 2s .co m*/ centers = filter; } return Lists.transform(centers, VectorConvert.TO_CENTERS); }
From source file:org.batoo.jpa.core.impl.criteria.expression.ConcatExpression.java
/** * {@inheritDoc}/*from w w w .j a v a2 s . c o m*/ * */ @Override public String generateJpqlRestriction(final BaseQueryImpl<?> query) { final String expressions = Joiner.on(", ") .join(Lists.transform(this.arguments, new Function<Expression<String>, String>() { @Override public String apply(Expression<String> input) { return ((AbstractExpression<String>) input).generateJpqlRestriction(query); } })); return "concat (" + expressions + ")"; }
From source file:org.apache.shindig.gadgets.preload.ConcurrentPreloads.java
private Collection<PreloadedData> getData() { return Lists.transform(tasks, new Function<Future<PreloadedData>, PreloadedData>() { public PreloadedData apply(Future<PreloadedData> preloadedDataFuture) { return getPreloadedData(preloadedDataFuture); }// w w w . ja va 2 s.c o m }); }