Example usage for com.google.common.collect Maps newLinkedHashMap

List of usage examples for com.google.common.collect Maps newLinkedHashMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newLinkedHashMap.

Prototype

public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() 

Source Link

Document

Creates a mutable, empty, insertion-ordered LinkedHashMap instance.

Usage

From source file:net.roddrim.number5.tools.collect.FluentMap.java

public static <K, V> FluentMap<K, V> ofNewLinkedHashMap() {
    return of(Maps.newLinkedHashMap());
}

From source file:org.apache.parquet.tools.read.SimpleMapRecord.java

@Override
protected Object toJsonObject() {
    Map<String, Object> result = Maps.newLinkedHashMap();
    for (NameValue value : values) {
        String key = null;//from w  ww  .  j  ava 2 s . c  om
        Object val = null;
        for (NameValue kv : ((SimpleRecord) value.getValue()).values) {
            String kvName = kv.getName();
            Object kvValue = kv.getValue();
            if (kvName.equals("key")) {
                key = keyToString(kvValue);
            } else if (kvName.equals("value")) {
                val = toJsonValue(kvValue);
            }
        }
        result.put(key, val);
    }
    return result;
}

From source file:org.apache.isis.applib.fixturescripts.ExecutionParameters.java

static Map<String, String> asKeyValueMap(final String parameters) {
    final Map<String, String> keyValues = Maps.newLinkedHashMap();
    if (parameters != null) {
        try {/*from   www . j  av a  2 s .  c o m*/
            final ImmutableList<String> lines = CharSource.wrap(parameters).readLines();
            for (final String line : lines) {
                if (line == null) {
                    continue;
                }
                final Matcher matcher = keyEqualsValuePattern.matcher(line);
                if (matcher.matches()) {
                    keyValues.put(matcher.group(1).trim(), matcher.group(2).trim());
                }
            }
        } catch (final IOException e) {
            // ignore, shouldn't happen
        }
    }
    return keyValues;
}

From source file:com.cinchapi.common.base.CaseFormats.java

/**
 * Generates all possible case formats for a given set of strings.
 * //from  w  w  w .j av  a2 s .com
 * @param strings
 * @return a {@link Set} that contains all possible {@link CaseFormat case
 *         formats} for each of the {@code strings}
 */
public static Map<String, CaseFormat> allVariationsOf(String... strings) {
    Map<String, CaseFormat> formatted = Maps.newLinkedHashMap();
    CaseFormat[] formats = CaseFormat.values();
    for (String string : strings) {
        CaseFormat original = detect(string);
        formatted.put(string, original);
        for (CaseFormat target : Arrays.stream(formats).filter(Predicates.equalTo(original).negate())
                .collect(Collectors.toList())) {
            formatted.put(original.to(target, string), target);
        }
    }
    return formatted;
}

From source file:de.xaniox.heavyspleef.core.module.ModuleManager.java

public ModuleManager(Logger logger) {
    this.logger = logger;
    this.modules = Maps.newLinkedHashMap();
}

From source file:org.gradle.external.javadoc.internal.JavadocOptionFile.java

private static Map<String, JavadocOptionFileOptionInternal<?>> duplicateOptions(
        Map<String, JavadocOptionFileOptionInternal<?>> original) {
    Map<String, JavadocOptionFileOptionInternal<?>> duplicateOptions = Maps.newLinkedHashMap();
    for (Map.Entry<String, JavadocOptionFileOptionInternal<?>> entry : original.entrySet()) {
        duplicateOptions.put(entry.getKey(), entry.getValue().duplicate());
    }//from   ww w .  jav a 2s  . c  o  m
    return duplicateOptions;
}

From source file:net.opentsdb.contrib.tsquare.LookupNamedAggregatorFactory.java

public void setAggregators(Map<String, Aggregator> aggregatorsMap) {
    this.aggregators = Maps.newLinkedHashMap();

    for (final Map.Entry<String, Aggregator> entry : aggregatorsMap.entrySet()) {
        this.aggregators.put(entry.getKey().toLowerCase(), entry.getValue());
    }/* w  w  w.j a  v  a  2 s .  c om*/
}

From source file:sg.atom.utils.datastructure.parser.ToLowerCaseParser.java

@Override
public Map parse(String input) throws FormattedException {
    Map<String, Object> line = baseParser.parse(input);
    Map<String, Object> retVal = Maps.newLinkedHashMap();
    for (Map.Entry<String, Object> entry : line.entrySet()) {
        String k = entry.getKey().toLowerCase();

        if (retVal.containsKey(k)) {
            // Duplicate key, case-insensitively
            throw new FormattedException.Builder().withErrorCode(FormattedException.ErrorCode.UNPARSABLE_ROW)
                    .withMessage(String.format("Duplicate key [%s]", k)).build();
        }/*from w w w. ja v  a 2s  .c o m*/

        retVal.put(k, entry.getValue());
    }
    return retVal;
}

From source file:net.opentsdb.contrib.tsquare.web.view.ResponseContext.java

public ResponseContext(final HttpServletRequest request, final HttpServletResponse response) {
    this.request = request;
    this.response = response;
    this.properties = Maps.newLinkedHashMap();
}

From source file:org.terasology.reflection.copy.strategy.MapCopyStrategy.java

@Override
public Map<K, V> copy(Map<K, V> map) {
    if (map != null) {
        Map<K, V> result = Maps.newLinkedHashMap();
        for (Map.Entry<K, V> entry : map.entrySet()) {
            result.put(keyStrategy.copy(entry.getKey()), valueStrategy.copy(entry.getValue()));
        }/*from ww  w .  ja  v  a  2  s. c om*/
        return result;
    }
    return null;
}