List of usage examples for com.google.common.collect Maps uniqueIndex
public static <K, V> ImmutableMap<K, V> uniqueIndex(Iterator<V> values, Function<? super V, K> keyFunction)
From source file:org.obm.push.bean.change.hierarchy.Folder.java
public static ImmutableMap<BackendId, Folder> mapByBackendId(Iterable<Folder> folders) { return Maps.uniqueIndex(folders, new Function<Folder, BackendId>() { @Override/*from w w w . j av a 2s . c o m*/ public BackendId apply(Folder folder) { return folder.getBackendId(); } }); }
From source file:de.metas.ui.web.globalaction.GlobalActionsDispatcher.java
public GlobalActionsDispatcher(final Optional<List<GlobalActionHandler>> handlers) { if (handlers.isPresent()) { this.handlers = Maps.uniqueIndex(handlers.get(), GlobalActionHandler::getTypeHandled); logger.info("Registered handlers: {}", handlers); } else {//from ww w. ja va 2 s. c o m this.handlers = ImmutableMap.of(); logger.warn("No handlers registered"); } }
From source file:org.opendaylight.controller.cluster.databroker.actors.dds.BouncingReconnectForwarder.java
static ReconnectForwarder forCohorts(final ConnectedClientConnection<?> successor, final Collection<HistoryReconnectCohort> cohorts) { return new BouncingReconnectForwarder(successor, Maps.uniqueIndex(Collections2.transform(cohorts, HistoryReconnectCohort::getProxy), ProxyReconnectCohort::getIdentifier)); }
From source file:azkaban.serialization.de.ExecutableFlowDeserializer.java
@Override public ExecutableFlow apply(Map<String, Object> descriptor) { Map<String, ExecutableFlow> jobs = Maps.uniqueIndex( Iterables.<Map<String, Object>, ExecutableFlow>transform( Verifier.getVerifiedObject(descriptor, "jobs", Map.class).values(), jobDeserializer), new Function<ExecutableFlow, String>() { @Override//from ww w .j a v a 2 s . c o m public String apply(ExecutableFlow flow) { return flow.getName(); } }); Map<String, List<String>> dependencies = Verifier.getVerifiedObject(descriptor, "dependencies", Map.class); List<String> roots = Verifier.getVerifiedObject(descriptor, "root", List.class); String id = Verifier.getString(descriptor, "id"); return buildFlow(id, roots, dependencies, jobs); }
From source file:org.polarsys.reqcycle.types.impl.ExtensionPointReader.java
public Map<String, IType> read() { return Maps.uniqueIndex(Iterables.filter(Iterables.transform( Arrays.asList(/*from w w w .jav a2 s .co m*/ Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID, EXT_ID)), new Conf2Type()), Predicates.notNull()), new Function<IType, String>() { public String apply(IType type) { return type != null ? type.getId() : ""; } }); }
From source file:com.facebook.buck.rules.coercer.StringWithMacrosTypeCoercer.java
static StringWithMacrosTypeCoercer from(ImmutableMap<String, Class<? extends Macro>> macros, ImmutableList<MacroTypeCoercer<? extends Macro>> coercers) { return new StringWithMacrosTypeCoercer(macros, Maps.uniqueIndex(coercers, MacroTypeCoercer::getOutputClass)); }
From source file:com.google.security.zynamics.binnavi.disassembly.CCallgraph.java
/** * Creates a new Call graph object./*from w ww . j a v a 2 s .c om*/ * * @param nodes The nodes of the Call graph. * @param edges The edges of the Call graph. */ public CCallgraph(final List<ICallgraphNode> nodes, final List<ICallgraphEdge> edges) { super(nodes, edges); m_functionMap = Maps.uniqueIndex(nodes, new Function<ICallgraphNode, INaviFunction>() { @Override public INaviFunction apply(final ICallgraphNode input) { return input.getFunction(); } }); }
From source file:org.gradle.plugins.ide.eclipse.internal.EclipseNameDeduper.java
public void configureRoot(Project rootProject) { Set<Project> projects = Sets.filter(rootProject.getAllprojects(), HAS_ECLIPSE_PLUGIN); ImmutableMap<EclipseProject, Project> eclipseProjects = Maps.uniqueIndex(projects, GET_ECLIPSE_PROJECT); HierarchicalElementDeduplicator<EclipseProject> deduplicator = new HierarchicalElementDeduplicator<EclipseProject>( new EclipseDeduplicationAdapter(eclipseProjects)); Map<EclipseProject, String> deduplicated = deduplicator.deduplicate(eclipseProjects.keySet()); for (Map.Entry<EclipseProject, String> entry : deduplicated.entrySet()) { entry.getKey().setName(entry.getValue()); }//from w ww .ja v a2 s.c om }
From source file:org.sonar.server.computation.measure.MetricCache.java
public MetricCache(DbClient dbClient) { DbSession dbSession = dbClient.openSession(false); try {/*from w w w . j a va 2s .c o m*/ List<MetricDto> metricList = dbClient.metricDao().selectEnabled(dbSession); this.metrics = Maps.uniqueIndex(metricList, new Function<MetricDto, String>() { @Override public String apply(MetricDto metric) { return metric.getKey(); } }); } finally { MyBatis.closeQuietly(dbSession); } }
From source file:net.sourceforge.ganttproject.io.OptionSaver.java
public void saveOptionList(TransformerHandler handler, Iterable<GPOption<?>> options) throws SAXException { saveOptionMap(Maps.uniqueIndex(options, new Function<GPOption<?>, String>() { @Override//from ww w.j a va 2 s . c o m public String apply(GPOption<?> value) { return value.getID(); } }).entrySet(), handler); }