Example usage for com.google.common.collect ListMultimap get

List of usage examples for com.google.common.collect ListMultimap get

Introduction

In this page you can find the example usage for com.google.common.collect ListMultimap get.

Prototype

@Override
List<V> get(@Nullable K key);

Source Link

Document

Because the values for a given key may have duplicates and follow the insertion ordering, this method returns a List , instead of the java.util.Collection specified in the Multimap interface.

Usage

From source file:org.dishevelled.bio.alignment.sam.SamFields.java

/**
 * Parse the Type=B first letter f field value for the specified key into an immutable list of floats.
 *
 * @param key key, must not be null// ww  w.  ja  v a  2  s  .c o  m
 * @param fields fields, must not be null
 * @return the Type=f first letter f field value for the specified key parsed into an immutable list of floats
 */
static List<Float> parseFloats(final String key, final ListMultimap<String, String> fields) {
    checkNotNull(key);
    checkNotNull(fields);
    return parseFloats(fields.get(key));
}

From source file:org.dishevelled.bio.alignment.sam.SamFields.java

/**
 * Parse the Type=B first letter [cCsSiI] field value for the specified key into an immutable list of integers.
 *
 * @param key key, must not be null/*from  w ww.  j ava 2 s. co  m*/
 * @param fields fields, must not be null
 * @return the Type=B first letter [cCsSiI] field value for the specified key parsed into an immutable list of integers
 */
static List<Integer> parseIntegers(final String key, final ListMultimap<String, String> fields) {
    checkNotNull(key);
    checkNotNull(fields);
    return parseIntegers(fields.get(key));
}

From source file:eu.esdihumboldt.hale.common.align.model.functions.merge.MergeUtil.java

/**
 * Get the properties defined in a Merge function property parameter.
 * //w  ww. j a  v  a  2  s  .  c  om
 * @param parameters the parameters multimap
 * @param parameterName the parameter name
 * @return the list of properties identified by their property paths
 */
public static List<List<QName>> getProperties(ListMultimap<String, ParameterValue> parameters,
        String parameterName) {
    List<List<QName>> result = new ArrayList<List<QName>>();
    if (parameters.containsKey(parameterName)) {
        for (ParameterValue property : parameters.get(parameterName)) {
            result.add(getPropertyPath(property));
        }
    }
    return result;
}

From source file:org.dishevelled.bio.alignment.sam.SamFields.java

/**
 * Parse the Type=A field value for the specified key into a character.
 *
 * @param key key, must not be null/*from w w w  . j a  va2  s.c  o m*/
 * @param fields fields, must not be null
 * @return the Type=A field value for the specified key parsed into a character
 */
static char parseCharacter(final String key, final ListMultimap<String, String> fields) {
    checkNotNull(key);
    checkNotNull(fields);

    List<String> values = fields.get(key);
    if (values.isEmpty()) {
        throw new IllegalArgumentException("Type=A value missing for key " + key);
    }
    if (values.size() > 1) {
        throw new IllegalArgumentException("more than one Type=A value for key " + key);
    }
    return toChar(values.get(0));
}

From source file:org.dishevelled.bio.alignment.sam.SamFields.java

/**
 * Parse the Type=i field value for the specified key into an integer.
 *
 * @param key key, must not be null/*w  w  w.  java 2 s .c o m*/
 * @param fields fields, must not be null
 * @return the Type=i field value for the specified key parsed into an integer
 */
static int parseInteger(final String key, final ListMultimap<String, String> fields) {
    checkNotNull(key);
    checkNotNull(fields);

    List<String> values = fields.get(key);
    if (values.isEmpty()) {
        throw new IllegalArgumentException("Type=i value missing for key " + key);
    }
    if (values.size() > 1) {
        throw new IllegalArgumentException("more than one Type=i value for key " + key);
    }
    return Integer.valueOf(values.get(0));
}

From source file:org.dishevelled.bio.alignment.sam.SamFields.java

/**
 * Parse the Type=f field value for the specified key into a float.
 *
 * @param key key, must not be null/*from w w w . ja v a  2 s .c om*/
 * @param fields fields, must not be null
 * @return the Type=f field value for the specified key parsed into a float
 */
static float parseFloat(final String key, final ListMultimap<String, String> fields) {
    checkNotNull(key);
    checkNotNull(fields);

    List<String> values = fields.get(key);
    if (values.isEmpty()) {
        throw new IllegalArgumentException("Type=f value missing for key " + key);
    }
    if (values.size() > 1) {
        throw new IllegalArgumentException("more than one Type=f value for key " + key);
    }
    return Float.valueOf(values.get(0));
}

From source file:org.dishevelled.bio.alignment.sam.SamFields.java

/**
 * Return the Type=Z field value for the specified key as a string.
 *
 * @param key key, must not be null/*from  ww w  .  ja  v  a  2s  .c o  m*/
 * @param fields fields, must not be null
 * @return the Type=Z field value for the specified key as a string
 */
static String parseString(final String key, final ListMultimap<String, String> fields) {
    checkNotNull(key);
    checkNotNull(fields);

    List<String> values = fields.get(key);
    if (values.isEmpty()) {
        throw new IllegalArgumentException("Type=Z value missing for key " + key);
    }
    if (values.size() > 1) {
        throw new IllegalArgumentException("more than one Type=Z value for key " + key);
    }
    return values.get(0);
}

From source file:org.dishevelled.bio.alignment.sam.SamFields.java

/**
 * Return the Type=H field value for the specified key as a byte array.
 *
 * @param key key, must not be null//from   w ww.j  a  v a 2 s  .  c o  m
 * @param fields fields, must not be null
 * @return the Type=H field value for the specified key as a byte array
 */
static byte[] parseByteArray(final String key, final ListMultimap<String, String> fields) {
    checkNotNull(key);
    checkNotNull(fields);

    List<String> values = fields.get(key);
    if (values.isEmpty()) {
        throw new IllegalArgumentException("Type=H value missing for key " + key);
    }
    if (values.size() > 1) {
        throw new IllegalArgumentException("more than one Type=H value for key " + key);
    }
    try {
        return decodeHex(values.get(0));
    } catch (DecoderException e) {
        throw new IllegalArgumentException("could not decode hex value for key " + key, e);
    }
}

From source file:org.dishevelled.bio.variant.vcf.header.VcfHeaderLineParser.java

/**
 * Return the required flag value for the specified key.
 *
 * @param key key, must not be null/*from ww w  .  ja va2s. c  o  m*/
 * @param entries entries, must not be null
 * @return the required flag value for the specified key
 */
static String requiredString(final String key, final ListMultimap<String, String> entries) {
    checkNotNull(key);
    checkNotNull(entries);
    List<String> values = entries.get(key);
    if (values.isEmpty()) {
        throw new IllegalArgumentException("required key " + key + " not found");
    }
    if (values.size() > 1) {
        throw new IllegalArgumentException("found more than one value for required key " + key);
    }
    return values.get(0);
}

From source file:org.dishevelled.bio.variant.vcf.header.VcfHeaderLineParser.java

/**
 * Return the optional string value, if any.
 *
 * @param key key, must not be null//from   w ww  . j  av  a  2  s  . c  om
 * @param entries entries, must not be null
 * @return the optional string value, or null if no such value exists
 */
static String optionalString(final String key, final ListMultimap<String, String> entries) {
    checkNotNull(key);
    checkNotNull(entries);

    List<String> values = entries.get(key);
    if (values.isEmpty()) {
        return null;
    }
    if (values.size() > 1) {
        throw new IllegalArgumentException("found more than one value for optional key " + key);
    }
    return values.get(0);
}