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:org.eclipse.xtext.builder.clustering.CopiedResourceDescription.java
public CopiedResourceDescription(IResourceDescription original) { this.uri = original.getURI(); this.exported = ImmutableList.copyOf(Iterables.transform(original.getExportedObjects(), new Function<IEObjectDescription, IEObjectDescription>() { @Override//from w ww.jav a 2s . co m public IEObjectDescription apply(IEObjectDescription from) { if (from.getEObjectOrProxy().eIsProxy()) { return from; } InternalEObject result = (InternalEObject) EcoreUtil.create(from.getEClass()); result.eSetProxyURI(from.getEObjectURI()); Map<String, String> userData = null; for (final String key : from.getUserDataKeys()) { if (userData == null) { userData = Maps.newHashMapWithExpectedSize(2); } userData.put(key, from.getUserData(key)); } return EObjectDescription.create(from.getName(), result, userData); } })); }
From source file:org.eclipse.xtext.scoping.impl.LoadOnDemandResourceDescriptions.java
@Override public Iterable<IResourceDescription> getAllResourceDescriptions() { return Iterables.filter(Iterables.transform(validUris, new Function<URI, IResourceDescription>() { @Override// w ww .j a v a 2s. c o m public IResourceDescription apply(URI from) { return getResourceDescription(from); } }), Predicates.notNull()); }
From source file:org.openrdf.sail.elasticsearch.ElasticsearchDocumentScore.java
@Override public Iterable<String> getSnippets(String field) { HighlightField highlightField = hit.getHighlightFields().get(field); if (highlightField == null) { return null; }//from w ww .j a v a 2s .co m return Iterables.transform(Arrays.asList(highlightField.getFragments()), new Function<Text, String>() { @Override public String apply(Text fragment) { return SearchFields.getSnippet(fragment.string()); } }); }
From source file:brooklyn.location.docker.strategy.LabelPlacementStrategy.java
@Override public boolean apply(DockerHostLocation input) { Set<String> labels = MutableSet.copyOf(config().get(LABELS)); if (labels.isEmpty()) return true; Set<String> tags = MutableSet .copyOf(Iterables.transform(input.getMachine().tags().getTags(), Functions.toStringFunction())); labels.removeAll(tags);//w ww. j a v a2 s . co m LOG.debug("Host {} : Tags {} : Remaining {}", new Object[] { input, Iterables.toString(tags), labels.isEmpty() ? "none" : Iterables.toString(labels) }); return labels.isEmpty(); }
From source file:brooklyn.rest.transform.EffectorTransformer.java
public static EffectorSummary effectorSummaryForCatalog(Effector<?> effector) { Set<EffectorSummary.ParameterSummary<?>> parameters = ImmutableSet.copyOf(Iterables.transform( effector.getParameters(), new Function<ParameterType<?>, EffectorSummary.ParameterSummary<?>>() { @Override//from w w w. j a va 2 s. c o m public EffectorSummary.ParameterSummary<?> apply(ParameterType<?> parameterType) { return parameterSummary(null, parameterType); } })); return new EffectorSummary(effector.getName(), effector.getReturnTypeName(), parameters, effector.getDescription(), null); }
From source file:com.facebook.buck.cxx.platform.WindowsPreprocessor.java
@Override public Iterable<String> quoteIncludeArgs(Iterable<String> includeRoots) { return Iterables.transform(includeRoots, prependIncludeFlag); }
From source file:jflowmap.geo.MapProjections.java
public static Iterable<Point> projectAll(Iterable<Point> points, final MapProjection mapProjection) { return Iterables.transform(points, new Function<Point, Point>() { @Override//from w ww . j a v a2 s .c o m public Point apply(Point from) { return Point.valueOf(mapProjection.project(from.x(), from.y())); } }); }
From source file:org.obiba.opal.web.security.SubjectCredentialsGroupAuthorizationResource.java
@GET public Iterable<Opal.Acl> get(@QueryParam("domain") @DefaultValue("opal") String domain, @QueryParam("type") SubjectType type) { SubjectAcl.Subject aclSubject = type.subjectFor(subject); Collection<SubjectAclService.Permissions> permissions = new HashSet<>(); for (SubjectAclService.Permissions p : subjectAclService.getSubjectPermissions(aclSubject)) { if (p.getDomain().equals(domain)) { permissions.add(p);/*ww w . ja v a 2 s. c o m*/ } } return Iterables.transform(permissions, PermissionsToAclFunction.INSTANCE); }
From source file:com.yahoo.yqlplus.engine.internal.plan.ConstantExpressionEvaluator.java
public List<Object> apply(List<OperatorNode<ExpressionOperator>> input) { return Lists.newArrayList(Iterables.transform(input, this)); }
From source file:com.facebook.buck.apple.xcode.FrameworkPath.java
public static FrameworkPath fromString(BuildTarget target, String string) { Path path = Paths.get(string); String firstElement = Preconditions.checkNotNull(Iterables.getFirst(path, Paths.get(""))).toString(); if (firstElement.startsWith("$")) { // NOPMD - length() > 0 && charAt(0) == '$' is ridiculous Optional<PBXReference.SourceTree> sourceTree = PBXReference.SourceTree.fromBuildSetting(firstElement); if (sourceTree.isPresent()) { return ImmutableFrameworkPath.builder() .sourceTreePath(new SourceTreePath(sourceTree.get(), path.subpath(1, path.getNameCount()))) .build();/* w w w . j av a2s.c o m*/ } else { throw new HumanReadableException(String.format( "Unknown SourceTree: %s in target: %s. Should be one of: %s", firstElement, target, Joiner.on(',') .join(Iterables.transform(ImmutableList.copyOf(PBXReference.SourceTree.values()), new Function<PBXReference.SourceTree, String>() { @Override public String apply(PBXReference.SourceTree input) { return "$" + input.toString(); } })))); } } else { return ImmutableFrameworkPath.builder().sourcePath(new BuildTargetSourcePath(target, Paths.get(string))) .build(); } }