List of usage examples for com.google.common.collect Multimaps unmodifiableMultimap
@Deprecated public static <K, V> Multimap<K, V> unmodifiableMultimap(ImmutableMultimap<K, V> delegate)
From source file:org.eclipse.emf.compare.rcp.EMFCompareRCPPlugin.java
/** * Set the Adapter Factory Registry.// w w w . j av a 2s. c om * * @param registry * {@link IExtensionRegistry} to listen in order to fill the registry */ private void setUpAdapterFactoryRegistry(final IExtensionRegistry registry) { adapterFactoryRegistryBackingMultimap = Multimaps.synchronizedListMultimap( ArrayListMultimap.<Collection<?>, RankedAdapterFactoryDescriptor>create()); adapterFactoryRegistryListener = new AdapterFactoryDescriptorRegistryListener( EMFCompareEditPlugin.PLUGIN_ID, FACTORY_PPID, getLog(), adapterFactoryRegistryBackingMultimap); registry.addListener(adapterFactoryRegistryListener, EMFCompareEditPlugin.PLUGIN_ID + '.' + FACTORY_PPID); adapterFactoryRegistryListener.readRegistry(registry); rankedAdapterFactoryRegistry = new RankedAdapterFactoryDescriptorRegistryImpl( ComposedAdapterFactory.Descriptor.Registry.INSTANCE, Multimaps.unmodifiableMultimap(adapterFactoryRegistryBackingMultimap)); }
From source file:com.puppetlabs.geppetto.validation.runner.AllModulesState.java
/** * Returns an unmodifiable {@link Multimap} containing exports per File, * where a given File is a reference to a module directory. * * @return//from w w w. j a va 2s . co m */ private Multimap<File, Export> getExportMap() { return Multimaps.unmodifiableMultimap(exportMap != null ? exportMap : EmptyExports); }
From source file:org.apache.tez.history.parser.datamodel.DagInfo.java
public Multimap<Container, TaskAttemptInfo> getContainerMapping() { return Multimaps.unmodifiableMultimap(containerMapping); }
From source file:com.b2international.snowowl.datastore.server.CDORepositoryManager.java
private Multimap<String, CDORemoteSession> getRemoteSessions() { LifecycleUtil.checkActive(this); final HashMultimap<String, CDORemoteSession> $ = HashMultimap.create(); for (final ICDORepository repository : this) { final String uuid = repository.getUuid(); final ICDOConnection connection = ApplicationContext.getInstance() .getService(ICDOConnectionManager.class).getByUuid(uuid); final CDORemoteSessionManager remoteSessionManager = connection.getSession().getRemoteSessionManager(); for (final CDORemoteSession session : remoteSessionManager.getElements()) { $.put(session.getUserID(), session); }//from w w w. jav a 2 s .c om } return Multimaps.unmodifiableMultimap($); }
From source file:org.apache.tez.history.parser.datamodel.VertexInfo.java
public final Multimap<Container, TaskAttemptInfo> getContainersMapping() { Multimap<Container, TaskAttemptInfo> containerMapping = LinkedHashMultimap.create(); for (TaskAttemptInfo attemptInfo : getTaskAttempts()) { containerMapping.put(attemptInfo.getContainer(), attemptInfo); }/* ww w. j av a 2 s . c om*/ return Multimaps.unmodifiableMultimap(containerMapping); }
From source file:com.puppetlabs.geppetto.validation.runner.AllModulesState.java
/** * Returns an unmodifiable {@link Multimap} of the full information Module * -> unresolved names/file/locations. * * @return//from w ww .j a v a 2s. c om */ public Multimap<File, ImportedName> getUnresolved() { return Multimaps.unmodifiableMultimap(unresolvedImports); }
From source file:financial.market.GeographicalMarket.java
/** * this happens at FINAL priority, so all quotes have been settled. * It keeps rescheduling itself to iterate one more buyer * @param state/*from w ww . j a va2 s .c om*/ */ @Override public void step(SimState state) { if (!isActive) return; MacroII model = (MacroII) state; /** * if the map has changed since the last step, reset the iterator */ if (changedMap) { indexToLoopTo = 0; changedMap = false; } //let's go! Iterator<GeographicalCustomer> buyerIterator = buyersWhoPlacedAQuote.keySet().iterator(); for (int i = 0; i < indexToLoopTo; i++) { assert buyerIterator.hasNext(); //should never fail, because we have been here before! buyerIterator.next(); //already processed } //if there are no more buyers or sellers, we are done! if (!buyerIterator.hasNext() || sellersWhoPlacedAQuote.isEmpty()) { //restart this tomorrow indexToLoopTo = 0; model.scheduleTomorrow(ActionOrder.TRADE, this, Priority.FINAL); return; } //okay, then there is another buyer to process, let's do this GeographicalCustomer currentBuyer = buyerIterator.next(); //make him choose among all the possible buyers GeographicalFirm sellerChosen = currentBuyer .chooseSupplier(Multimaps.unmodifiableMultimap(sellersWhoPlacedAQuote)); if (sellerChosen != null) { //remove the seller quote Quote sellerQuoteChosen = sellersWhoPlacedAQuote.get(sellerChosen).iterator().next(); //remove the buyer quote Quote buyerQuoteToRemove = buyersWhoPlacedAQuote.get(currentBuyer).iterator().next(); //make them trade! int finalPrice = pricePolicy.price(sellerQuoteChosen.getPriceQuoted(), buyerQuoteToRemove.getPriceQuoted()); //make them trade! Good goodBought = sellerQuoteChosen.getGood(); PurchaseResult result = trade(currentBuyer, sellerChosen, goodBought, finalPrice, sellerQuoteChosen, buyerQuoteToRemove); if (result == PurchaseResult.BUYER_HAS_NO_MONEY) throw new Bankruptcy(currentBuyer); assert result == PurchaseResult.SUCCESS; //remove the two crossing quotes boolean removedCorrectly = sellersWhoPlacedAQuote.remove(sellerChosen, sellerQuoteChosen); assert removedCorrectly; removedCorrectly = buyersWhoPlacedAQuote.remove(currentBuyer, buyerQuoteToRemove); assert removedCorrectly; //reactions! currentBuyer.reactToFilledBidQuote(buyerQuoteToRemove, goodBought, finalPrice, sellerChosen); sellerChosen.reactToFilledAskedQuote(sellerQuoteChosen, goodBought, finalPrice, currentBuyer); } else { //move on! indexToLoopTo++; } //reschedule yourself the same day! model.scheduleSoon(ActionOrder.TRADE, this, Priority.FINAL); }
From source file:org.jboss.weld.annotated.enhanced.jlr.EnhancedAnnotatedTypeImpl.java
protected Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> buildAnnotatedMethodMultimap( Set<EnhancedAnnotatedMethod<?, ? super T>> effectiveMethods) { Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> result = HashMultimap.create(); for (EnhancedAnnotatedMethod<?, ? super T> method : effectiveMethods) { for (Class<? extends Annotation> annotation : MAPPED_METHOD_ANNOTATIONS) { if (method.isAnnotationPresent(annotation)) { result.put(annotation, method); }/*from www . j a va 2s.co m*/ } } return Multimaps.unmodifiableMultimap(result); }
From source file:com.puppetlabs.geppetto.validation.runner.AllModulesState.java
public void setRestricted(Multimap<String, String> restricted) { if (restricted == null) throw new IllegalArgumentException("null 'restricted'"); this.restricted = Multimaps.unmodifiableMultimap(restricted); }
From source file:org.jboss.weld.annotated.enhanced.jlr.EnhancedAnnotatedTypeImpl.java
protected Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> buildAnnotatedParameterMethodMultimap( Set<EnhancedAnnotatedMethod<?, ? super T>> effectiveMethods) { Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> result = HashMultimap.create(); for (EnhancedAnnotatedMethod<?, ? super T> method : effectiveMethods) { for (Class<? extends Annotation> annotation : MAPPED_METHOD_PARAMETER_ANNOTATIONS) { if (!method.getEnhancedParameters(annotation).isEmpty()) { result.put(annotation, method); }//from w w w. j av a 2 s .c om } } return Multimaps.unmodifiableMultimap(result); }