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:com.proofpoint.cloudmanagement.service.ProviderResource.java
@GET @Produces(MediaType.APPLICATION_JSON)// ww w.j a v a 2 s . c o m public Response getProvider(@PathParam("provider") final String provider, @Context final UriInfo uriInfo) { checkNotNull(provider); checkNotNull(uriInfo); if (!instanceConnectorMap.containsKey(provider)) { return Response.status(Status.NOT_FOUND).build(); } InstanceConnector instanceConnector = instanceConnectorMap.get(provider); Provider providerRepresentation = new Provider(provider, instanceConnector.getName(), Iterables.transform(instanceConnector.getLocations(), new Function<Location, Location>() { @Override public Location apply(@Nullable Location input) { return Location.fromLocationAndSelfUri(input, ProviderLocationResource.constructSelfUri(provider, input.getLocation(), uriInfo)); } }), constructSelfUri(uriInfo, provider)); return Response.ok(providerRepresentation).build(); }
From source file:org.obiba.opal.web.project.permissions.ProjectDatasourcePermissionsResource.java
/** * Get all datasource-level permissions in the project. * * @param domain/*from w w w .ja va 2s . co m*/ * @param type * @return */ @GET public Iterable<Opal.Acl> getDatasourcePermissions(@QueryParam("type") SubjectType type) { // make sure datasource exists MagmaEngine.get().getDatasource(name); Iterable<SubjectAclService.Permissions> permissions = subjectAclService .getNodePermissions(ProjectPermissionsResource.DOMAIN, getNode(), type); return Iterables.transform(permissions, PermissionsToAclFunction.INSTANCE); }
From source file:org.gradle.model.internal.manage.schema.cache.MultiWeakClassSet.java
@Override public boolean equals(Object obj) { if (obj instanceof MultiWeakClassSet) { MultiWeakClassSet other = Cast.uncheckedCast(obj); if (other.references.size() == references.size()) { return Iterables.elementsEqual(Iterables.transform(other.references, UNPACK_REF), Iterables.transform(references, UNPACK_REF)); }// w w w .ja v a2 s . co m } return false; }
From source file:com.facebook.buck.cxx.toolchain.ClangPreprocessor.java
@Override public final Iterable<String> quoteIncludeArgs(Iterable<String> includeRoots) { return MoreIterables.zipAndConcat(Iterables.cycle("-iquote"), Iterables.transform(includeRoots, MorePaths::pathWithUnixSeparators)); }
From source file:org.jclouds.openstack.nova.compute.strategy.NovaListNodesStrategy.java
@Override public Iterable<? extends NodeMetadata> listDetailsOnNodesMatching(Predicate<ComputeMetadata> filter) { return Iterables.filter( Iterables.transform(client.listServers(ListOptions.Builder.withDetails()), serverToNodeMetadata), filter);//from www .j ava 2s . co m }
From source file:edu.ucsb.eucalyptus.msgs.CallerContext.java
public void apply(final BaseMessage message) { message.setUserId(identity);//from www . j a v a2 s. c o m if (privileged) { message.markPrivileged(); } message.setCallerContext(new BaseCallerContext(Lists.newArrayList( Iterables.transform(evaluatedKeys.entrySet(), MapEntryToEvaluatedIamConditionKey.INSTANCE)))); }
From source file:com.linkedin.bowser.core.functions.Dir.java
@Override public NQLObject apply(Map<String, NQLObject> globals, java.util.List<NQLObject> arguments) { assertNumberOfArguments(arguments, 0, 1); java.util.List<String> attributes = Lists.newArrayList(); if (arguments.isEmpty()) attributes.addAll(globals.keySet()); else {/* ww w. j a va 2 s. c o m*/ NQLObject arg = arguments.get(0); if (arg instanceof Attributable) { Attributable attributable = (Attributable) arg; attributes.addAll(attributable.getAttributes()); } } Collections.sort(attributes); return new ListObject(Lists.newArrayList(Iterables.transform(attributes, new Function<String, NQLObject>() { @Override public NQLObject apply(String attribute) { return Objects.create(attribute); } }))); }
From source file:org.eclipse.xtext.ui.editor.StatefulResourceDescription.java
protected ImmutableList<IEObjectDescription> copyExportedObjects(IResourceDescription original) { return ImmutableList.copyOf(Iterables.filter(Iterables.transform(original.getExportedObjects(), new Function<IEObjectDescription, IEObjectDescription>() { @Override// w w w .j ava 2 s. c o m public IEObjectDescription apply(IEObjectDescription from) { if (from == null) return null; EObject proxy = from.getEObjectOrProxy(); if (proxy == null) return null; if (proxy.eIsProxy()) return from; InternalEObject result = (InternalEObject) EcoreUtil.create(from.getEClass()); result.eSetProxyURI(EcoreUtil.getURI(from.getEObjectOrProxy())); Map<String, String> userData = null; for (String key : from.getUserDataKeys()) { if (userData == null) { userData = Maps.newHashMapWithExpectedSize(2); } userData.put(key, from.getUserData(key)); } return EObjectDescription.create(from.getName(), result, userData); } }), Predicates.notNull())); }
From source file:org.gradle.internal.component.AmbiguousConfigurationSelectionException.java
private static String generateMessage(AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, List<ConfigurationMetadata> matches, ComponentResolveMetadata targetComponent) { Set<String> ambiguousConfigurations = Sets.newTreeSet(Lists.transform(matches, CONFIG_NAME)); Set<String> requestedAttributes = Sets .newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME)); StringBuilder sb = new StringBuilder( "Cannot choose between the following configurations on '" + targetComponent + "' : "); JOINER.appendTo(sb, ambiguousConfigurations); sb.append(". All of them match the consumer attributes:"); sb.append("\n"); int maxConfLength = maxLength(ambiguousConfigurations); // We're sorting the names of the configurations and later attributes // to make sure the output is consistently the same between invocations for (final String ambiguousConf : ambiguousConfigurations) { formatConfiguration(sb, fromConfigurationAttributes, consumerSchema, matches, requestedAttributes, maxConfLength, ambiguousConf); }/*w w w .j a va 2 s.com*/ return sb.toString(); }
From source file:de.brands4friends.daleq.core.ImmutableTableData.java
@Override public Iterable<Optional<String>> getValuesOfField(final String fieldName) { final FieldType fieldType = new NamedFieldTypeReference(fieldName).resolve(tableType); if (fieldType == null) { throw new NoSuchDaleqFieldException( "Table " + tableType.getName() + " does not contain the Field " + fieldName); }//from ww w . j a v a 2 s . c o m return Iterables.transform(rows, new Function<RowData, Optional<String>>() { @Override public Optional<String> apply(@Nullable final RowData row) { if (row == null) { return null; } return row.getFieldBy(fieldName).getValue(); } }); }