List of usage examples for com.google.common.collect Multimap put
boolean put(@Nullable K key, @Nullable V value);
From source file:org.jclouds.sts.options.FederatedUserOptions.java
@Override public Multimap<String, String> buildFormParameters() { Multimap<String, String> params = super.buildFormParameters(); if (durationSeconds != null) params.put("DurationSeconds", durationSeconds.toString()); if (policy != null) params.put("Policy", policy); return params; }
From source file:org.deephacks.confit.model.Bean.java
public static Bean read(BeanId beanId, byte[] data) { if (ids == null) { ids = UniqueIds.lookup();//from w w w . ja v a 2 s .c om } Preconditions.checkNotNull(beanId); Preconditions.checkNotNull(data); Schema schema = beanId.getSchema(); Preconditions.checkNotNull(schema); Bean bean = Bean.create(beanId); ValueReader reader = new ValueReader(data); Multimap<String, String> properties = ArrayListMultimap.create(); Multimap<String, BeanId> references = ArrayListMultimap.create(); int[] propertyIds = reader.getIds(); for (int id : propertyIds) { String propertyName = ids.getSchemaName(id); Object value = reader.getValue(id); if (schema.isProperty(propertyName)) { if (Collection.class.isAssignableFrom(value.getClass())) { properties.putAll(propertyName, conversion.convert((Collection) value, String.class)); } else { properties.put(propertyName, conversion.convert(value, String.class)); } } else if (schema.isReference(propertyName)) { String schemaName = schema.getReferenceSchemaName(propertyName); if (Collection.class.isAssignableFrom(value.getClass())) { for (String instanceId : (Collection<String>) value) { references.put(propertyName, BeanId.create(instanceId, schemaName)); } } else { String instanceId = (String) value; references.put(propertyName, BeanId.create(instanceId, schemaName)); } } else { throw new IllegalArgumentException("Unrecognized property " + propertyName); } } for (String propertyName : properties.keySet()) { bean.addProperty(propertyName, properties.get(propertyName)); } for (String propertyName : references.keySet()) { bean.addReference(propertyName, references.get(propertyName)); } bean.set(schema); return bean; }
From source file:vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelArmor.java
@Override public Multimap getItemAttributeModifiers() { Multimap multimap = HashMultimap.create(); UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0); multimap.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) getArmorDisplay(null, new ItemStack(this), type) / 20, 0)); return multimap; }
From source file:prm4jeval.dataanalysis.TableParser2.java
public void put(String x, String y, double value) { Multimap<String, Double> multimap = result.get(x); if (multimap == null) { multimap = ArrayListMultimap.create(); result.put(x, multimap);/*from w ww . j a v a 2 s . c om*/ } multimap.put(y, value); }
From source file:springfox.documentation.spring.web.plugins.DefaultRequestHandlerCombiner.java
public List<RequestHandler> combine(List<RequestHandler> source) { List<RequestHandler> combined = new ArrayList<RequestHandler>(); Multimap<String, RequestHandler> byPath = LinkedListMultimap.create(); for (RequestHandler each : nullToEmptyList(source)) { byPath.put(patternsCondition(each).toString(), each); }//from w ww . j av a 2s . c o m for (String key : byPath.keySet()) { combined.addAll(combined(byPath.get(key))); } return byPatternsCondition().sortedCopy(combined); }
From source file:com.android.tools.lint.checks.WrongIdDetector.java
private static List<String> getSpellingSuggestions(String id, Collection<String> ids) { int maxDistance = id.length() >= 4 ? 2 : 1; // Look for typos and try to match with custom views and android views Multimap<Integer, String> matches = ArrayListMultimap.create(2, 10); int count = 0; if (!ids.isEmpty()) { for (String matchWith : ids) { matchWith = stripIdPrefix(matchWith); if (Math.abs(id.length() - matchWith.length()) > maxDistance) { // The string lengths differ more than the allowed edit distance; // no point in even attempting to compute the edit distance (requires // O(n*m) storage and O(n*m) speed, where n and m are the string lengths) continue; }// w ww. j a v a2 s . c om int distance = editDistance(id, matchWith); if (distance <= maxDistance) { matches.put(distance, matchWith); } if (count++ > 100) { // Make sure that for huge projects we don't completely grind to a halt break; } } } for (int i = 0; i < maxDistance; i++) { Collection<String> strings = matches.get(i); if (strings != null && !strings.isEmpty()) { List<String> suggestions = new ArrayList<String>(strings); Collections.sort(suggestions); return suggestions; } } return Collections.emptyList(); }
From source file:org.franca.examples.validators.fidl.UniqueStateNameValidator.java
@Override public void validateModel(FModel model, ValidationMessageAcceptor messageAcceptor) { for (FInterface _interface : model.getInterfaces()) { FContract contract = _interface.getContract(); if (contract != null) { Multimap<String, FState> stateNameMap = ArrayListMultimap.create(); for (FState state : contract.getStateGraph().getStates()) { stateNameMap.put(state.getName(), state); }//from www . j av a 2 s .com for (String name : stateNameMap.keySet()) { Collection<FState> states = stateNameMap.get(name); if (states.size() > 1) { for (FState state : states) { messageAcceptor.acceptError("The name of the state is not unique!", state, FrancaPackage.Literals.FMODEL_ELEMENT__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } } } } } }
From source file:com.torodb.torod.db.postgresql.query.QueryStructureFilter.java
public static Multimap<Integer, QueryCriteria> filterStructures(StructuresCache cache, QueryCriteria queryCriteria) throws UndecidableCaseException { Processor.Result processorResult = PROCESSOR.process(queryCriteria); List<ProcessedQueryCriteria> processedQueryCriterias = processorResult.getProcessedQueryCriterias(); ExistRelation existRelation = processorResult.getExistRelation(); BiMap<Integer, DocStructure> allStructures = cache.getAllStructures(); Multimap<Integer, QueryCriteria> result = HashMultimap.create(allStructures.size(), processedQueryCriterias.size()); StructureQueryEvaluator structureQueryEvaluator = new StructureQueryEvaluator(); for (ProcessedQueryCriteria processedQueryCriteria : processedQueryCriterias) { for (Map.Entry<Integer, DocStructure> entry : allStructures.entrySet()) { if (structureConforms(structureQueryEvaluator, entry.getValue(), processedQueryCriteria.getStructureQuery())) { QueryCriteria dataQuery = getDataQuery(processedQueryCriteria, structureQueryEvaluator.getCandidateProvider(), existRelation); result.put(entry.getKey(), dataQuery); LOGGER.debug("Structure {} fulfil structure query {}. Data query: {}", entry.getKey(), processedQueryCriteria.getStructureQuery(), dataQuery); }/*ww w .j a v a 2 s .c om*/ } } return result; }
From source file:org.obm.sync.client.mailingList.MailingListClient.java
@Override public void removeMailingList(AccessToken token, Integer id) throws ServerFault { if (id == null) { return;//from www . j av a 2s . c o m } Multimap<String, String> params = initParams(token); params.put("id", id.toString()); executeVoid(token, "/mailingList/removeMailingList", params); }
From source file:org.obm.sync.client.mailingList.MailingListClient.java
@Override public void removeEmail(AccessToken token, Integer mailingListId, Integer emailId) throws ServerFault { if (mailingListId == null || emailId == null) { return;// w w w .j a va 2s. c o m } Multimap<String, String> params = initParams(token); params.put("mailingListId", mailingListId.toString()); params.put("mailingListEmailId", emailId.toString()); executeVoid(token, "/mailingList/removeEmail", params); }