Example usage for com.google.common.collect Multimap put

List of usage examples for com.google.common.collect Multimap put

Introduction

In this page you can find the example usage for com.google.common.collect Multimap put.

Prototype

boolean put(@Nullable K key, @Nullable V value);

Source Link

Document

Stores a key-value pair in this multimap.

Usage

From source file:org.jboss.errai.common.metadata.ErraiPropertyScanner.java

public void scan(final Vfs.File file) {
    try {/*from w  w w . ja v  a2 s .  co  m*/
        final Properties properties = new Properties();
        properties.load(file.openInputStream());

        final Multimap<String, String> store = getStore();
        for (final Map.Entry<Object, Object> entry : properties.entrySet()) {
            store.put((String) entry.getKey(), (String) entry.getValue());
        }
    } catch (IOException e) {
        throw new RuntimeException("Failed to load properties: " + file.getFullPath(), e);
    }
}

From source file:org.jclouds.ohai.functions.MapSetToMultimap.java

@Override
public Multimap<K, V> apply(Map<K, Set<V>> from) {
    Multimap<K, V> returnV = LinkedHashMultimap.create();
    for (Entry<K, Set<V>> entry : from.entrySet()) {
        for (V value : entry.getValue())
            returnV.put(entry.getKey(), value);
    }//from  w  w w  .  ja va  2s  . co  m
    return returnV;
}

From source file:org.obm.sync.client.setting.SettingClient.java

@Override
public void setVacationSettings(AccessToken token, VacationSettings vs) throws ServerFault {
    Multimap<String, String> params = initParams(token);
    params.put("enabled", "" + vs.isEnabled());
    if (vs.isEnabled()) {
        if (vs.getStart() != null) {
            params.put("start", "" + vs.getStart().getTime());
        }/*from  ww w.ja  va 2s.  c o m*/
        if (vs.getEnd() != null) {
            params.put("end", "" + vs.getEnd().getTime());
        }
        params.put("text", "" + vs.getText());
    }
    Document doc = execute(token, "/setting/setVacationSettings", params);
    exceptionFactory.checkServerFaultException(doc);
}

From source file:parser.ScenarioDataParser.java

private void projectResult(Map.Entry<Path, List<String[]>> entry, Multimap<Path, Long> results) {
    for (String[] columns : entry.getValue()) {
        if (columns[1] == null) {
            continue;
        }/*w  w  w  .  j a  va 2s  .  co  m*/
        results.put(entry.getKey().getFileName(), Long.parseLong(columns[1]));
    }
}

From source file:com.zimbra.common.util.StringUtil.java

/**
 * Converts an old-style multimap to Guava's version.
 *//* w  ww  .  ja v a2s  .c o m*/
public static Multimap<String, String> toNewMultimap(Map<String, Object> oldMultimap) {
    Multimap<String, String> newMap = ArrayListMultimap.create();
    for (String key : oldMultimap.keySet()) {
        Object value = oldMultimap.get(key);
        if (value instanceof String[]) {
            for (String sVal : (String[]) value) {
                newMap.put(key, sVal);
            }
        } else if (value == null) {
            newMap.put(key, null);
        } else {
            newMap.put(key, value.toString());
        }
    }
    return newMap;
}

From source file:tachyony.nullPower.item.ItemHuntingRifle.java

/**
* Override to add custom weapon damage field rather than vanilla ItemSword's field
*//*from  w  ww  .j a  v a2 s  .co  m*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Multimap getItemAttributeModifiers() {
    Multimap multimap = HashMultimap.create();
    multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
            new AttributeModifier(field_111210_e, "Weapon modifier", weaponDamage, 0));
    return multimap;
}

From source file:org.jclouds.mezeo.pcs2.options.PutBlockOptions.java

@Override
public Multimap<String, String> buildRequestHeaders() {
    Multimap<String, String> headers = super.buildRequestHeaders();
    String range = getRange();//from  w w w.  j  a  v a 2s .c om
    if (range != null)
        headers.put("Content-Range", this.getRange());
    return headers;
}

From source file:adwords.axis.v201506.migration.MigrateToExtensionSettings.java

/**
 * Gets the feed mapping for a feed./*from w  w  w .j av  a  2 s .c o m*/
 *
 * @return a multimap from feed attribute ID to the set of field IDs mapped to the attribute
 */
private static Multimap<Long, Integer> getFeedMapping(AdWordsServices adWordsServices, AdWordsSession session,
        Feed feed, long placeholderType) throws Exception {
    // Get the FeedMappingService.
    FeedMappingServiceInterface feedMappingService = adWordsServices.get(session,
            FeedMappingServiceInterface.class);
    String query = String
            .format("SELECT FeedMappingId, AttributeFieldMappings WHERE FeedId = %d and PlaceholderType = %d "
                    + "AND Status = 'ENABLED'", feed.getId(), placeholderType);

    Multimap<Long, Integer> attributeMappings = HashMultimap.create();
    int offset = 0;
    FeedMappingPage feedMappingPage;

    do {
        String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
        feedMappingPage = feedMappingService.query(pageQuery);
        if (feedMappingPage.getEntries() != null) {
            // Normally, a feed attribute is mapped only to one field. However, you may map it to more
            // than one field if needed.
            for (FeedMapping feedMapping : feedMappingPage.getEntries()) {
                for (AttributeFieldMapping attributeMapping : feedMapping.getAttributeFieldMappings()) {
                    attributeMappings.put(attributeMapping.getFeedAttributeId(), attributeMapping.getFieldId());
                }
            }
        }
        offset += PAGE_SIZE;
    } while (offset < feedMappingPage.getTotalNumEntries());

    return attributeMappings;
}

From source file:de.minigames.mclib.nms.v18.items.CustomPickaxe.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override/*w  w  w  .ja  v a 2 s .c  o m*/
public Multimap i() {
    Multimap localMultimap = super.i();

    localMultimap.put(GenericAttributes.e.getName(),
            new AttributeModifier(f, "Tool modifier", this.attackDmg, 0)); //$NON-NLS-1$

    return localMultimap;
}

From source file:grakn.core.graql.reasoner.utils.conversion.SchemaConceptConverter.java

/**
 * convert a given type to a map of relation types in which it can play roles
 * and the corresponding role types including entity type hierarchy
 * @param entryConcept to be converted//from  ww w  . j ava 2s. c o  m
 * @return map of relation types in which it can play roles and the corresponding role types
 */
default Multimap<RelationType, Role> toRelationMultimap(T entryConcept) {
    Multimap<RelationType, Role> relationMap = HashMultimap.create();

    toCompatibleRoles(entryConcept)
            .forEach(role -> role.relations().forEach(rel -> relationMap.put(rel, role)));
    return relationMap;
}