List of usage examples for com.google.common.collect Collections2 transform
public static <F, T> Collection<T> transform(Collection<F> fromCollection, Function<? super F, T> function)
From source file:net.shibboleth.idp.consent.audit.impl.CurrentConsentValuesAuditExtractor.java
/** {@inheritDoc} */ @Override// w w w . j a v a 2 s . co m @Nullable public Collection<String> apply(@Nullable final ProfileRequestContext input) { final ConsentContext consentContext = consentContextLookupStrategy.apply(input); if (consentContext != null && !consentContext.getCurrentConsents().isEmpty()) { return Collections2.transform(consentContext.getCurrentConsents().values(), new Function<Consent, String>() { public String apply(final Consent input) { return input.getValue(); } }); } else { return Collections.emptyList(); } }
From source file:com.payu.ratel.client.inmemory.RatelServerFetcher.java
@Override public Collection<String> fetchServiceAddresses(final String serviceName) { Preconditions.checkNotNull(serviceName, "Please provide service name"); final Collection<ServiceDescriptor> serviceInstances = Collections2.filter(getAllServiceInstances(), new Predicate<ServiceDescriptor>() { @Override//from w w w .jav a2 s.com public boolean apply(ServiceDescriptor serviceDescriptor) { return serviceName.equals(serviceDescriptor.getName()); } }); return Collections2.transform(serviceInstances, new Function<ServiceDescriptor, String>() { @Override public String apply(ServiceDescriptor serviceDescriptor) { return serviceDescriptor.getAddress(); } }); }
From source file:org.sosy_lab.cpachecker.core.reachedset.UnmodifiableReachedSetView.java
@Override public Collection<AbstractState> asCollection() { return Collections2.transform(underlying.asCollection(), mapStateFunction); }
From source file:com.addthis.bundle.util.ConvertingSetView.java
@Override public boolean retainAll(Collection<?> c) { return source.retainAll(Collections2.transform(c, inputConverter::apply)); }
From source file:com.thinkbiganalytics.metadata.rest.api.ExtensionsController.java
/** * gets the extensible types in Kylo/* w w w .j a v a2 s .co m*/ * * @return a list of extensible type descriptors */ @Path("type") @GET @Produces(MediaType.APPLICATION_JSON) public List<ExtensibleTypeDescriptor> getTypes() { return metadata.read(() -> { this.accessController.checkPermission(AccessController.SERVICES, MetadataAccessControl.ACCESS_METADATA); List<ExtensibleType> list = this.typeProvider.getTypes(); return new ArrayList<>(Collections2.transform(list, ExtensiblesModel.DOMAIN_TO_TYPE)); }); }
From source file:org.richfaces.cdk.resource.scan.impl.reflections.ReflectionsExt.java
public Collection<Class<?>> getMarkedClasses() { Map<String, Multimap<String, String>> storeMap = getStore().getStoreMap(); Multimap<String, String> scannerMMap = storeMap.get(MarkerResourcesScanner.class.getName()); if (scannerMMap == null) { return Collections.emptySet(); }//from w w w . ja va 2 s. c o m return Collections2.filter( Collections2.transform(scannerMMap.get(MarkerResourcesScanner.STORE_KEY), CLASS_FOR_NAME), Predicates.notNull()); }
From source file:br.com.ingenieux.mojo.beanstalk.bg.BluegreenDeploymentMojo.java
@Override protected Object executeInternal() throws Exception { versionLabel = lookupVersionLabel(applicationName, versionLabel); getLog().info(format("Using version %s", versionLabel)); Collection<EnvironmentDescription> envs = new WaitForEnvironmentCommand(this) .lookupInternal(new WaitForEnvironmentContextBuilder().withApplicationName(applicationName) .withEnvironmentRef(environmentNamePrefix + "*").build()); if (envs.size() > 2) { final Collection<String> environmentList = Collections2.transform(envs, new Function<EnvironmentDescription, String>() { @Override//from w ww. ja v a2 s . c o m public String apply(EnvironmentDescription input) { return format("%s[%s]", input.getEnvironmentId(), input.getEnvironmentName()); } }); String message = "Ooops. There are multiple environments matching the lookup spec: " + environmentList; getLog().warn(message); getLog().warn("Will pick one at random anyway as long as it uses WebServer tier name"); } String otherEnvId = null; for (EnvironmentDescription e : envs) { if (!e.getEnvironmentId().equals(curEnv.getEnvironmentId()) && "WebServer".equals(e.getTier().getName())) { otherEnvId = e.getEnvironmentId(); break; } } getLog().info( format("(Green) Environment with environmentId['%s'] will be prepared once its ready to update", curEnv.getEnvironmentId())); new WaitForEnvironmentCommand(this).execute(new WaitForEnvironmentContextBuilder() .withStatusToWaitFor("Ready").withApplicationName(applicationName) .withEnvironmentRef(curEnv.getEnvironmentId()).build()); getLog().info( format("(Blue) Environment with environmentId['%s'] will be prepared once its ready to update", otherEnvId)); new WaitForEnvironmentCommand(this) .execute(new WaitForEnvironmentContextBuilder().withStatusToWaitFor("Ready") .withApplicationName(applicationName).withEnvironmentRef(otherEnvId).build()); getLog().info(format("(Blue) Updating environmentId to version %s", versionLabel)); new UpdateEnvironmentCommand(this).execute(new UpdateEnvironmentContextBuilder() .withEnvironmentId(otherEnvId).withVersionLabel(versionLabel).build()); getLog().info(format("(Blue) Waiting for environmentId['%s'] to get ready and green prior to switching", otherEnvId)); new WaitForEnvironmentCommand(this).execute(new WaitForEnvironmentContextBuilder() .withStatusToWaitFor("Ready").withApplicationName(applicationName).withHealth("Green") .withEnvironmentRef(otherEnvId).build()); getLog().info(format("Ok. Switching")); getService().swapEnvironmentCNAMEs(new SwapEnvironmentCNAMEsRequest() .withDestinationEnvironmentId(curEnv.getEnvironmentId()).withSourceEnvironmentId(otherEnvId)); getLog().info(format("Done.")); return null; //To change body of implemented methods use File | Settings | File Templates. }
From source file:org.elasticsearch.common.collect.CopyOnWriteHashSet.java
/** * Copy the current set and return a copy that is the union of the current * set and <code>entries</code>, potentially replacing existing entries in * case of equality.//ww w . j av a2 s . c o m */ public CopyOnWriteHashSet<T> copyAndAddAll(Collection<? extends T> entries) { final Collection<Entry<T, Boolean>> asMapEntries = Collections2.transform(entries, new Function<T, Map.Entry<T, Boolean>>() { @Override public Entry<T, Boolean> apply(T input) { return Maps.immutableEntry(input, true); } }); CopyOnWriteHashMap<T, Boolean> updated = this.map.copyAndPutAll(asMapEntries); return new CopyOnWriteHashSet<>(updated); }
From source file:com.github.ferstl.maven.pomenforcers.ErrorReport.java
public <T> ErrorReport addDiff(Collection<T> actual, Collection<T> required, String leftTitle, String rightTitle, Function<? super T, String> toStringFunction) { Collection<String> actualAsString = Collections2.transform(actual, toStringFunction); Collection<String> requiredAsString = Collections2.transform(required, toStringFunction); return addDiff(actualAsString, requiredAsString, leftTitle, rightTitle); }
From source file:com.kegare.caveworld.util.CaveUtils.java
public static List<ConfigCategory> getConfigCategories(final Configuration config) { return Lists.newArrayList( Collections2.transform(config.getCategoryNames(), new Function<String, ConfigCategory>() { @Override//from www . jav a2s .co m public ConfigCategory apply(String category) { return config.getCategory(category); } })); }