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:gt.org.ms.api.global.exceptions.ExceptionsManager.java
public static RuntimeException newValidationException(String cause, String error) { return new ValidationException( Lists.transform(Arrays.asList(new String[] { error }), new Function<String, ValidationError>() { @Override// w ww . ja v a 2 s . c om public ValidationError apply(String f) { return splitError(f); } })); }
From source file:de.csenk.gwt.commons.bean.rebind.SourceGeneration.java
/** * @param method// w w w .j a v a2 s. com * @return */ public static String getBaseMethodDeclaration(JMethod method) { final List<String> paramDeclarations = Lists.transform(Lists.newArrayList(method.getParameters()), new Function<JParameter, String>() { @Override @Nullable public String apply(@Nullable JParameter input) { return String.format("%s %s", ModelUtils.getQualifiedBaseSourceName(input.getType()), input.getName()); } }); final List<String> throwDeclarations = Lists.transform(Lists.newArrayList(method.getThrows()), new Function<JType, String>() { @Override @Nullable public String apply(@Nullable JType input) { return ModelUtils.getQualifiedBaseSourceName(input); } }); final String paramListDeclaration = Joiner.on(", ").join(paramDeclarations); final String throwsDeclaration = throwDeclarations.size() > 0 ? String.format("throws %s", Joiner.on(", ").join(throwDeclarations)) : ""; final String returnName = ModelUtils.getQualifiedBaseSourceName(method.getReturnType()); return String.format("%s %s(%s) %s", returnName, method.getName(), paramListDeclaration, throwsDeclaration); }
From source file:com.onboard.domain.transform.CompanyTransform.java
public static CompanyDTO companyAndProjectsToCompanyDTO(Company company, List<Project> projects) { CompanyDTO companyDTO = new CompanyDTO(); BeanUtils.copyProperties(company, companyDTO); companyDTO.setProjects(/* w ww. j a v a2 s. c o m*/ ImmutableList.copyOf(Lists.transform(projects, ProjectTransform.PROJECT_DTO_FUNCTION))); return companyDTO; }
From source file:org.caleydo.view.bicluster.util.TesselatedBiClusterPolygons.java
public static Band band(List<Vec2f> anchorPoints, final float z, float radiusFirst, float radiusSecond, int numberOfSplinePoints) { Preconditions.checkArgument(anchorPoints.size() >= 2, "at least two points"); List<Vec3f> curve = Splines.spline3(Lists.transform(anchorPoints, new Function<Vec2f, Vec3f>() { @Override/* w ww . j a v a 2 s . com*/ public Vec3f apply(Vec2f in) { return new Vec3f(in.x(), in.y(), z); } }), numberOfSplinePoints); return toBand(curve, radiusFirst, radiusSecond); }
From source file:domper.probe.android.service.Utils.java
static List<NamedValue> namedValueExtractor(Object object) { return Lists.transform(RecordItemExtractor.extract(object), recordItemToNamedValue); }
From source file:org.kududb.util.NetUtil.java
/** * Convert a list of {@link HostAndPort} objects to a comma separate string. * The inverse of {@link #parseStrings(String, int)}. * * @param hostsAndPorts A list of {@link HostAndPort} objects. * @return Comma separate list of "host:port" pairs. *//*from ww w . j a v a 2 s . co m*/ public static String hostsAndPortsToString(List<HostAndPort> hostsAndPorts) { return Joiner.on(",").join(Lists.transform(hostsAndPorts, Functions.toStringFunction())); }
From source file:io.druid.query.QueryMetricUtil.java
public static <T> ServiceMetricEvent.Builder makeQueryTimeMetric(Query<T> query) { return new ServiceMetricEvent.Builder().setUser2(DataSourceUtil.getMetricName(query.getDataSource())) .setUser4(query.getType())/*from w w w. j a v a 2 s. com*/ .setUser5(Lists.transform(query.getIntervals(), new Function<Interval, String>() { @Override public String apply(Interval input) { return input.toString(); } }).toArray(new String[query.getIntervals().size()])).setUser6(String.valueOf(query.hasFilters())) .setUser9(query.getDuration().toPeriod().toStandardMinutes().toString()); }
From source file:io.druid.segment.filter.Filters.java
public static List<Filter> convertDimensionFilters(List<DimFilter> filters) { return Lists.transform(filters, new Function<DimFilter, Filter>() { @Override//w w w .j a va 2s . c o m public Filter apply(@Nullable DimFilter input) { return convertDimensionFilters(input); } }); }
From source file:com.dangdang.ddframe.rdb.sharding.config.common.internal.ConfigUtil.java
public static List<String> transformCommaStringToList(final String strWithComma) { final GroovyShell shell = new GroovyShell(); return flattenList(Lists.transform(splitComma(strWithComma), new Function<String, Object>() { @Override/*from w w w . ja v a 2s. c om*/ public Object apply(final String input) { String compactInput = input.trim(); StringBuilder expression = new StringBuilder(compactInput); if (!compactInput.startsWith("\"")) { expression.insert(0, "\""); } if (!compactInput.endsWith("\"")) { expression.append("\""); } return shell.evaluate(expression.toString()); } })); }
From source file:sklearn.TypeUtil.java
static public DataType getDataType(List<?> objects, DataType defaultDataType) { Function<Object, Class<?>> function = new Function<Object, Class<?>>() { @Override// w w w .ja va 2 s .c om public Class<?> apply(Object object) { return object.getClass(); } }; Set<Class<?>> clazzes = new HashSet<>(Lists.transform(objects, function)); Class<?> clazz = Iterables.getOnlyElement(clazzes); DataType dataType = TypeUtil.dataTypes.get(clazz); if (dataType != null) { return dataType; } return defaultDataType; }