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:it.f2informatica.core.validator.utils.ErrorMessageResolver.java
public List<ErrorMessage> resolveErrorCodes(List<FieldError> fieldErrors, final Locale locale) { return Lists.newArrayList(Iterables.transform(fieldErrors, new Function<FieldError, ErrorMessage>() { @Override/* ww w.ja v a 2 s . c o m*/ public ErrorMessage apply(FieldError input) { String errorCode = input.getCode(); String errorMessage = messageSource.getMessage(errorCode, input.getArguments(), locale); String field = Iterables.getFirst(Arrays.asList(input.getField().split("\\.")), ""); return new ErrorMessage(field, errorCode, errorMessage); } })); }
From source file:com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils.java
/** Retrieves and casts {@link ConstraintValueInfo} providers from the given targets. */ public static Iterable<ConstraintValueInfo> constraintValues( Iterable<? extends SkylarkProviderCollection> targets) { return Iterables.transform(targets, PlatformProviderUtils::constraintValue); }
From source file:io.crate.execution.engine.collect.RowsTransformer.java
public static Iterable<Row> toRowsIterable(InputFactory inputFactory, ReferenceResolver<?> referenceResolver, RoutedCollectPhase collectPhase, Iterable<?> iterable) { WhereClause whereClause = collectPhase.whereClause(); if (whereClause.noMatch()) { return Collections.emptyList(); }// ww w. java 2 s . c o m InputFactory.Context ctx = inputFactory.ctxForRefs(referenceResolver); ctx.add(collectPhase.toCollect()); OrderBy orderBy = collectPhase.orderBy(); if (orderBy != null) { for (Symbol symbol : orderBy.orderBySymbols()) { ctx.add(symbol); } } @SuppressWarnings("unchecked") Iterable<Row> rows = Iterables.transform(iterable, new ValueAndInputRow<>(ctx.topLevelInputs(), ctx.expressions())); if (whereClause.hasQuery()) { assert DataTypes.BOOLEAN.equals( whereClause.query().valueType()) : "whereClause.query() must be of type " + DataTypes.BOOLEAN; //noinspection unchecked whereClause().query() is a symbol of type boolean so it must become Input<Boolean> rows = Iterables.filter(rows, InputCondition.asPredicate(ctx.add(whereClause.query()))); } if (orderBy == null) { return rows; } return sortRows(Iterables.transform(rows, Row::materialize), collectPhase); }
From source file:org.apache.isis.core.metamodel.facets.object.membergroups.annotprop.MemberGroupLayoutFacetProperties.java
static String[] asGroupList(Properties properties, final String key) { final String property = properties.getProperty(key); if (property == null) { return new String[0]; }//from w w w . j ava 2 s . c o m final Iterable<String> split = Splitter.on(',').split(property); return Iterables.toArray( Iterables.filter(Iterables.transform(split, StringFunctions.TRIM), StringPredicates.NOT_EMPTY), String.class); }
From source file:org.spongepowered.common.util.persistence.JsonTranslator.java
private static Object convert(JsonElement element) { if (element.isJsonObject()) { MemoryDataView container = new MemoryDataContainer(); for (Entry<String, JsonElement> entry : ((JsonObject) element).entrySet()) { Object value = convert(entry.getValue()); if (value != null) { container.set(DataQuery.of(entry.getKey()), value); }// w ww . ja v a 2 s. com } return container; } else if (element.isJsonArray()) { return Lists.newArrayList(Iterables.transform((JsonArray) element, JsonTranslator::convert)); } else if (element.isJsonPrimitive()) { JsonPrimitive primitive = (JsonPrimitive) element; if (primitive.isString()) { return primitive.getAsString(); } else if (primitive.isBoolean()) { return primitive.getAsBoolean(); } else if (primitive.isNumber()) { return primitive.getAsNumber(); } } return null; }
From source file:com.onboard.service.account.function.InvitationProjectFilter.java
public InvitationProjectFilter(Collection<InvitationProjects> existings) { this.existingProjectIds = ImmutableSet .copyOf(Iterables.transform(existings, new Function<InvitationProjects, Integer>() { @Override/*from ww w .ja v a 2 s . c o m*/ public Integer apply(InvitationProjects input) { return input.getProjectId(); } })); }
From source file:com.b2international.snowowl.snomed.dsl.query.SyntaxErrorException.java
@Override public String getMessage() { return Joiner.on("\n").join(Iterables.transform(syntaxErrors, new Function<INode, String>() { @Override/* w w w . j av a2s . co m*/ public String apply(final INode node) { return node.getSyntaxErrorMessage().getMessage(); } })); }
From source file:cosmos.sql.call.impl.Projection.java
public List<Field> getProjections() { return Lists.newArrayList(Iterables.transform(children.values(), new Function<CallIfc<?>, Field>() { @Override// w ww . j ava 2 s.co m public Field apply(CallIfc<?> child) { return (Field) child; } })); }
From source file:uk.ac.stfc.isis.ibex.configserver.json.PVsConverter.java
@Override public Collection<PV> convert(String[][] value) throws ConversionException { return Lists.newArrayList(Iterables.transform(Arrays.asList(value), new Function<String[], PV>() { @Override/*from w ww. j a v a 2 s.co m*/ public PV apply(String[] info) { return new PV(info[0], info[1], info[2], info[3]); } })); }
From source file:org.sonar.batch.issue.DefaultProjectIssues.java
@Override public Iterable<Issue> issues() { return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(false)), new IssueTransformer()); }