Java Code Examples for com.google.common.collect.HashMultimap#entries()
The following examples show how to use
com.google.common.collect.HashMultimap#entries() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIResourceChangeRegistry.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public void writeState(final OutputStream out) { try { final DataOutputStream writer = new DataOutputStream(out); for (final HashMultimap<String, URI> map : Collections.<HashMultimap<String, URI>>unmodifiableList(CollectionLiterals.<HashMultimap<String, URI>>newArrayList(this.existsListeners, this.charsetListeners, this.childrenListeners, this.contentsListeners))) { { final Set<Map.Entry<String, URI>> entries = map.entries(); writer.writeInt(entries.size()); for (final Map.Entry<String, URI> entry : entries) { { writer.writeUTF(entry.getKey()); writer.writeUTF(entry.getValue().toString()); } } } } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 2
Source File: JsonIngestHelper.java From datawave with Apache License 2.0 | 5 votes |
protected Multimap<String,NormalizedContentInterface> getGroupNormalizedMap(HashMultimap<String,String> fields) { Multimap<String,NormalizedContentInterface> results = HashMultimap.create(); for (Map.Entry<String,String> e : fields.entries()) { if (e.getValue() != null) { results.put(e.getKey(), new NormalizedFieldAndValue(e.getKey(), e.getValue())); } } return groupNormalizer.extractFieldNameComponents(results); }
Example 3
Source File: ElasticSearchRepository.java From pacbot with Apache License 2.0 | 5 votes |
/** * * @param filter * @return */ private List<Map<String, Object>> getFilter(final HashMultimap<String, Object> filter) { List<Map<String, Object>> finalFilter = Lists.newArrayList(); for (Map.Entry<String, Object> entry : filter.entries()) { Map<String, Object> term = Maps.newHashMap(); Map<String, Object> termDetails = Maps.newHashMap(); termDetails.put(entry.getKey(), entry.getValue()); term.put(TERM, termDetails); finalFilter.add(term); } return finalFilter; }
Example 4
Source File: CommonUtils.java From pacbot with Apache License 2.0 | 5 votes |
/** * Gets the filter. * * @param filter the filter * @return the filter */ private static List<Map<String, Object>> getFilter(final HashMultimap<String, Object> filter) { List<Map<String, Object>> finalFilter = Lists.newArrayList(); for (Map.Entry<String, Object> entry : filter.entries()) { Map<String, Object> term = Maps.newHashMap(); Map<String, Object> termDetails = Maps.newHashMap(); termDetails.put(entry.getKey(), entry.getValue()); term.put("term", termDetails); finalFilter.add(term); } return finalFilter; }
Example 5
Source File: PacmanUtils.java From pacbot with Apache License 2.0 | 5 votes |
/** * Gets the value from elastic search as set. * * @param esUrl the es url * @param mustFilterMap the must filter map * @param shouldFilterMap the should filter map * @param mustTermsFilterMap the must terms filter map * @param fieldKey the field key * @param matchPhrase the match phrase * @return the value from elastic search as set * @throws Exception the exception */ public static Set<String> getValueFromElasticSearchAsSet(String esUrl, Map<String,Object> mustFilterMap,HashMultimap<String, Object> shouldFilterMap,Map<String, Object> mustTermsFilterMap,String fieldKey,Map<String, List<String>> matchPhrase) throws Exception { JsonParser jsonParser = new JsonParser(); Map<String, Object> mustFilter = new HashMap<>(); HashMultimap<String, Object> shouldFilter = HashMultimap.create(); Map<String, Object> mustNotFilter = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); if (!mustFilterMap.isEmpty()) { for(Map.Entry<String,Object> mustFilMap: mustFilterMap.entrySet()){ mustFilter.put(convertAttributetoKeyword(mustFilMap.getKey()), mustFilMap.getValue()); } } if (!shouldFilterMap.isEmpty()) { for(Map.Entry<String,Object> shouldFilMap: shouldFilterMap.entries()){ shouldFilter.put(convertAttributetoKeyword(shouldFilMap.getKey()), shouldFilMap.getValue()); } } if (!mustTermsFilterMap.isEmpty()) { for(Map.Entry<String,Object> mustTermsFilMap: mustTermsFilterMap.entrySet()){ mustTermsFilter.put(convertAttributetoKeyword(mustTermsFilMap.getKey()), mustTermsFilMap.getValue()); } } JsonObject resultJson = RulesElasticSearchRepositoryUtil.getQueryDetailsFromES(esUrl+"?size=10000", mustFilter, mustNotFilter, shouldFilter, null, 0, mustTermsFilter, null,matchPhrase); if (resultJson != null && resultJson.has(PacmanRuleConstants.HITS)) { String hitsJsonString = resultJson.get(PacmanRuleConstants.HITS).toString(); JsonObject hitsJson = (JsonObject) jsonParser.parse(hitsJsonString); JsonArray jsonArray = hitsJson.getAsJsonObject().get(PacmanRuleConstants.HITS).getAsJsonArray(); return returnFieldValueAsSet(jsonArray,fieldKey); } return null; }
Example 6
Source File: RulesElasticSearchRepositoryUtil.java From pacbot with Apache License 2.0 | 5 votes |
/** * * @param filter * @return */ private static List<Map<String, Object>> getFilter( final HashMultimap<String, Object> filter) { List<Map<String, Object>> finalFilter = Lists.newArrayList(); for (Map.Entry<String, Object> entry : filter.entries()) { Map<String, Object> term = Maps.newHashMap(); Map<String, Object> termDetails = Maps.newHashMap(); termDetails.put(entry.getKey(), entry.getValue()); term.put("term", termDetails); finalFilter.add(term); } return finalFilter; }
Example 7
Source File: LingeringPotion.java From Et-Futurum with The Unlicense | 4 votes |
@Override @SideOnly(Side.CLIENT) @SuppressWarnings({ "rawtypes", "unchecked" }) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isComplex) { if (stack.getItemDamage() == 0) return; List<PotionEffect> effects = getEffects(stack); HashMultimap<String, AttributeModifier> attributes = HashMultimap.create(); if (effects == null || effects.isEmpty()) { String s = StatCollector.translateToLocal("potion.empty").trim(); list.add(EnumChatFormatting.GRAY + s); } else for (PotionEffect potioneffect : effects) { String s1 = StatCollector.translateToLocal(potioneffect.getEffectName()).trim(); Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; Map<IAttribute, AttributeModifier> map = potion.func_111186_k(); if (map != null && map.size() > 0) for (Entry<IAttribute, AttributeModifier> entry : map.entrySet()) { AttributeModifier attributemodifier = entry.getValue(); AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation()); attributes.put(entry.getKey().getAttributeUnlocalizedName(), attributemodifier1); } if (potioneffect.getAmplifier() > 0) s1 = s1 + " " + StatCollector.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim(); if (potioneffect.getDuration() > 20) s1 = s1 + " (" + Potion.getDurationString(potioneffect) + ")"; if (potion.isBadEffect()) list.add(EnumChatFormatting.RED + s1); else list.add(EnumChatFormatting.GRAY + s1); } if (!attributes.isEmpty()) { list.add(""); list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("potion.effects.whenDrank")); for (Entry<String, AttributeModifier> entry1 : attributes.entries()) { AttributeModifier attributemodifier2 = entry1.getValue(); double d0 = attributemodifier2.getAmount(); double d1; if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2) d1 = attributemodifier2.getAmount(); else d1 = attributemodifier2.getAmount() * 100.0D; if (d0 > 0.0D) list.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + entry1.getKey()) })); else if (d0 < 0.0D) { d1 *= -1.0D; list.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + entry1.getKey()) })); } } } }