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:co.freeside.betamax.message.httpclient.HttpMessageAdapter.java
@Override public final String getHeader(String name) { List<Header> headers = Arrays.asList(getDelegate().getHeaders(name)); List<String> headerValues = Lists.transform(headers, new Function<Header, String>() { @Override/*from ww w. j a va 2 s. com*/ public String apply(Header header) { return header.getValue(); } }); return Joiner.on(", ").skipNulls().join(headerValues); }
From source file:org.excalibur.discovery.ws.client.ProviderClient.java
public List<ProviderDetails> all() { List<?> providers = request("providers").accept(MediaType.APPLICATION_JSON_TYPE).get(List.class); return Lists.transform(providers, new Function<Object, ProviderDetails>() { @Override// w w w .j a va2s . com @Nullable public ProviderDetails apply(@Nullable Object input) { return RESOURCE_MAPPER.convertValue(input, ProviderDetails.class); } }); }
From source file:br.com.objectos.dojo.enanschau.gen.RelatorioDeAlunoGenGuice.java
@Override public List<RelatorioDeAluno> gerarDe(List<Aluno> alunos) { List<RelatorioDeAluno> res = Lists.transform(alunos, new ToRelatorioDeAluno()); return ImmutableList.copyOf(res); }
From source file:net.sourceforge.cilib.pso.crossover.velocityprovider.AverageParentsOffspringVelocityProvider.java
@Override public StructuredType f(List<Particle> parent, Particle offspring) { return Vectors.mean(Lists.transform(parent, new Function<Particle, Vector>() { @Override//from w ww .jav a 2s . co m public Vector apply(Particle f) { return (Vector) f.getVelocity(); } })); }
From source file:org.raml.jaxrs.generator.v08.V08Response.java
public V08Response(final Resource resource, final Method method, Response input, final Set<String> globalSchemas, final V08TypeRegistry registry) { this.response = input; this.bodies = Lists.transform(input.body(), new Function<BodyLike, GResponseType>() { @Nullable// w w w.j ava2 s.c o m @Override public GResponseType apply(@Nullable BodyLike input) { return new V08GResponseType(resource, method, response, input, globalSchemas, registry); } }); }
From source file:org.openengsb.core.services.internal.security.EntryUtils.java
/** * converts a list of {@link EntryElement} back to a list containing the original java objects. *///from w w w. jav a2s . c o m public static List<Object> convertAllEntryElementsToObject(List<EntryElement> value) { return Lists.transform(value, new EntryElementParserFunction()); }
From source file:org.raml.jaxrs.generator.v10.V10GResponse.java
public V10GResponse(final V10TypeRegistry registry, final V10GResource v10GResource, final Method method, final Response response) { this.v10GResource = v10GResource; this.response = response; this.bodies = Lists.transform(this.response.body(), new Function<TypeDeclaration, GResponseType>() { @Nullable//from w ww .j a v a 2s.c om @Override public GResponseType apply(@Nullable TypeDeclaration input) { if (TypeUtils.shouldCreateNewClass(input, input.parentTypes().toArray(new TypeDeclaration[0]))) { return new V10GResponseType(input, registry.fetchType(v10GResource.implementation(), method, response, input)); } else { // return new V10GResponseType(input, V10GTypeFactory // .createExplicitlyNamedType(registry, input.type(), input)); return new V10GResponseType(input, registry.fetchType(input.type(), input)); } } }); }
From source file:org.opentestsystem.shared.monitoringalerting.service.impl.DiscreteIntakeServiceImpl.java
@Override public String[] getDistinctAlertTypes() { return Iterables.toArray( Lists.transform(this.discreteIntakeRepository.findByType(TYPE.ALERT), VALUE_TRANSFORMER), String.class); }
From source file:com.github.nethad.clustermeister.api.impl.ConfigurationUtil.java
/** * This helps reading lists form the configuration that consist of * 'named objects', e.g. (YAML)://www .j a v a 2 s . c o m * * <pre> * list: * - name1: * key1: value * key2: value2 * - name2: * key1: value3 * key3: value4 * ... * </pre> * * More specifically it reduces a List<Map<String, Map<String, * String>>> as produced by above example to a Map<String, * Map<String, String>> like this (Java syntax, referring to above * example): * * <pre> * [ * name1 => [ * key1 => value, * key2 => value2 * ], * name2 => [ * key1 => value3, * key3 => value4 * ], * ... * ] * </pre> * * @param list the list to reduce. * @param errorMessage * Custom error message to add to exception in case of the * list not being convertible. * @return A map reduced as described above. * @throws IllegalArgumentException if the list can not be converted in * this manner. */ public static Map<String, Map<String, String>> reduceObjectList(List<Object> list, String errorMessage) { try { Map<String, Map<String, String>> result = Maps.newLinkedHashMap(); List<Map<String, Map<String, String>>> mapList = Lists.transform(list, new Function<Object, Map<String, Map<String, String>>>() { @Override public Map apply(Object input) { return (Map<String, Map<String, String>>) input; } }); for (Map<String, Map<String, String>> map : mapList) { for (Map.Entry<String, Map<String, String>> entry : map.entrySet()) { String key = entry.getKey(); Map<String, String> value = entry.getValue(); for (Map.Entry<String, String> valueEntry : value.entrySet()) { Object valueValue = valueEntry.getValue(); valueEntry.setValue(String.valueOf(valueValue)); } result.put(key, value); } } return result; } catch (ClassCastException ex) { throw new IllegalArgumentException(errorMessage, ex); } }
From source file:org.caleydo.core.view.opengl.util.spline.TesselatedPolygons.java
/** * create a band based on a set of 2d curve points * * @param anchorPoints//from w ww. j a v a 2 s . c o m * @param z * @param radius * radius of the band * @param numberOfSplinePoints * @return */ public static Band band(List<Vec2f> anchorPoints, final float z, float radius, int numberOfSplinePoints) { Preconditions.checkArgument(anchorPoints.size() >= 2, "at least two points"); List<Vec3f> curve = Splines.spline3(Lists.transform(anchorPoints, new Function<Vec2f, Vec3f>() { @Override public Vec3f apply(Vec2f in) { return new Vec3f(in.x(), in.y(), z); } }), numberOfSplinePoints); return toBand(curve, radius); }