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.eucalyptus.auth.policy.PolicyPrincipal.java
public PolicyPrincipal(final boolean notPrincipal, @Nonnull final PrincipalType type, @Nonnull final Set<String> values) { checkParam("type", type, notNullValue()); checkParam("values", values, notNullValue()); this.type = type; this.values = ImmutableSet.copyOf(Iterables.transform(values, PolicyUtils.internString())); this.notPrincipal = notPrincipal; }
From source file:org.apache.cassandra.schema.Views.java
public Iterable<CFMetaData> metadatas() { return Iterables.transform(views.values(), view -> view.metadata); }
From source file:org.obiba.opal.web.system.permissions.AdministrationPermissionsResource.java
/** * Get administration permissions.//from w w w . jav a2 s .c o m * * @param domain * @param type * @return */ @GET public Iterable<Opal.Acl> getAdministrationPermissions(@QueryParam("type") SubjectType type) { Iterable<SubjectAclService.Permissions> permissions = subjectAclService.getNodePermissions(DOMAIN, getNode(), type); return Iterables.transform(permissions, PermissionsToAclFunction.INSTANCE); }
From source file:shaded.org.openqa.selenium.remote.server.handler.internal.ResultConverter.java
public Object apply(Object result) { if (result instanceof WebElement) { String elementId = knownElements.add((WebElement) result); return ImmutableMap.of("ELEMENT", elementId); }// ww w .j a va 2 s . c o m if (result instanceof List) { @SuppressWarnings("unchecked") List<Object> resultAsList = (List<Object>) result; return Lists.newArrayList(Iterables.transform(resultAsList, this)); } if (result instanceof Map<?, ?>) { Map<?, ?> resultAsMap = (Map<?, ?>) result; Map<Object, Object> converted = Maps.newHashMapWithExpectedSize(resultAsMap.size()); for (Map.Entry<?, ?> entry : resultAsMap.entrySet()) { converted.put(entry.getKey(), apply(entry.getValue())); } return converted; } if (result instanceof ResultSet) { Map<Object, Object> converted = Maps.newHashMap(); converted.put("insertId", ((ResultSet) result).getLastInsertedRowId()); converted.put("rowsAffected", ((ResultSet) result).getNumberOfRowsAffected()); ResultSetRows rsRows = ((ResultSet) result).rows(); List<Map<String, Object>> rows = Lists.newArrayList(); for (int i = 0; i < rsRows.size(); i++) { rows.add(rsRows.item(i)); } converted.put("rows", Lists.newArrayList(Iterables.transform(rows, this))); return converted; } return result; }
From source file:org.apache.brooklyn.entity.nosql.mongodb.sharding.MongoDBConfigServerClusterImpl.java
@Override public void start(Collection<? extends Location> locs) { super.start(locs); // TODO this should be an enricher Iterable<String> memberHostNamesAndPorts = Iterables.transform(getMembers(), new Function<Entity, String>() { @Override//from w w w. ja v a 2s . c o m public String apply(Entity entity) { HostAndPort hostAndPort = BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, entity.getAttribute(MongoDBConfigServer.PORT)); return hostAndPort.getHostText() + ":" + hostAndPort.getPort(); } }); sensors().set(MongoDBConfigServerCluster.CONFIG_SERVER_ADDRESSES, ImmutableList.copyOf(memberHostNamesAndPorts)); }
From source file:org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers.java
@Override public Set<LoadBalancer> apply(HttpResponse arg0) { Map<String, Set<LB>> map = json.apply(arg0); if (map.size() == 0) return ImmutableSet.<LoadBalancer>of(); ;//from ww w . j a va 2 s . c o m return ImmutableSet.copyOf(Iterables.transform(Iterables.get(map.values(), 0), convertLB)); }
From source file:org.javersion.util.PersistentMap.java
default Iterable<K> keys() { return Iterables.transform(this, MapUtils.<K>mapKeyFunction()); }
From source file:org.killbill.billing.usage.api.svcs.DefaultInternalUserApi.java
@Override public List<RawUsage> getRawUsageForAccount(final LocalDate stateDate, final LocalDate endDate, final InternalTenantContext internalTenantContext) { final List<RolledUpUsageModelDao> usage = rolledUpUsageDao.getRawUsageForAccount(stateDate, endDate, internalTenantContext);// w w w .j a v a 2 s . c o m return ImmutableList.copyOf(Iterables.transform(usage, new Function<RolledUpUsageModelDao, RawUsage>() { @Nullable @Override public RawUsage apply(final RolledUpUsageModelDao input) { return new DefaultRawUsage(input.getSubscriptionId(), input.getRecordDate(), input.getUnitType(), input.getAmount()); } })); }
From source file:cosmos.results.CloseableIterable.java
public static <T> CloseableIterable<T> filterAndTransform(ScannerBase scanner, Predicate<Entry<Key, Value>> filter, Function<Entry<Key, Value>, T> func, Tracer t, String desc, Stopwatch sw) {/*from w ww . j a va 2 s.c o m*/ return new CloseableIterable<T>(scanner, Iterables.transform(Iterables.filter(scanner, filter), func), t, desc, sw); }
From source file:org.apache.aurora.scheduler.async.preemptor.LiveClusterState.java
@Override public Multimap<String, PreemptionVictim> getSlavesToActiveTasks() { // Only non-pending active tasks may be preempted. Iterable<IAssignedTask> activeTasks = Iterables.transform(Storage.Util.fetchTasks(storage, CANDIDATE_QUERY), SCHEDULED_TO_ASSIGNED);/*w w w . ja v a 2s . com*/ // Group the tasks by slave id so they can be paired with offers from the same slave. // Choosing to do this iteratively instead of using Multimaps.index/transform to avoid // generating a very large intermediate map. ImmutableMultimap.Builder<String, PreemptionVictim> tasksBySlave = ImmutableMultimap.builder(); for (IAssignedTask task : activeTasks) { tasksBySlave.put(task.getSlaveId(), PreemptionVictim.fromTask(task)); } return tasksBySlave.build(); }