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:com.homeadvisor.kafdrop.config.ini.IniFilePropertySource.java

private static Map<String, Object> loadPropertiesForIniFile(IniFileProperties iniProperties,
        String[] activeProfiles) {
    final Map<String, Object> properties = Maps.newLinkedHashMap();
    properties.putAll(iniProperties.getDefaultProperties());

    if (activeProfiles != null && activeProfiles.length > 0) {
        for (String profile : activeProfiles) {
            final Map<String, String> sectionProperties = iniProperties.getSectionProperties(profile);
            if (sectionProperties != null) {
                properties.putAll(sectionProperties);
            }//from   w ww . java 2  s.  c  om
        }
    }
    return properties;
}

From source file:org.zoumbox.tarot.engine.StatisticsHelper.java

public static LinkedHashMap<String, Statistics> getStatistics(List<PlayerBoard> boards) {
    LinkedHashMap<String, Statistics> result = Maps.newLinkedHashMap();
    for (PlayerBoard board : boards) {

        List<Deal> deals = board.getDeals();
        int dealCount = deals.size();
        for (String player : board.getScores().keySet()) {
            Statistics statistics = getStatistics(result, player);
            statistics.addDealCount(dealCount);
        }/*from www.  j  a va  2 s .com*/

        for (Deal deal : deals) {
            String taker = deal.getTaker();
            Statistics statistics = result.get(taker);
            Contract contract = deal.getContract();
            boolean won = deal.isWon();
            statistics.newPartyTaken(contract, won);
        }
    }
    return result;
}

From source file:org.sonar.api.test.ReviewContextTestUtils.java

public static ReviewContext createReviewContext(String properties) {
    Map<String, Map<String, String>> reviewContextMap = Maps.newLinkedHashMap();
    for (String innerMap : StringUtils.split(properties, ';')) {
        if (StringUtils.isNotBlank(innerMap)) {
            String mapName = StringUtils.substringBefore(innerMap, "=").trim();
            Map<String, String> currentMap = Maps.newLinkedHashMap();
            for (String keyValuePairList : StringUtils.substringsBetween(innerMap, "{", "}")) {
                for (String keyValuePair : StringUtils.split(keyValuePairList, ',')) {
                    currentMap.put(StringUtils.substringBefore(keyValuePair, "=").trim(),
                            StringUtils.substringAfter(keyValuePair, "=").trim());
                }//from  w w w  .  j a  v  a 2s  . c o m
            }
            reviewContextMap.put(mapName, currentMap);
        }
    }

    return ReviewContext.createFromMap(reviewContextMap);
}

From source file:me.hzhou.ext.jfinal.kit.KeyLabel.java

public static Map<String, String> converListToMap(List<KeyLabel> list) {
    Map<String, String> map = Maps.newLinkedHashMap();
    for (KeyLabel k : list) {
        map.put(k.getKey(), k.getLabel());
    }//w  w  w . j  a  va2  s .  co m

    return map;
}

From source file:org.apache.isis.viewer.restfulobjects.rendering.util.MapUtils.java

/**
 * Returns an immutable map based on a list of key/value pairs.
 *//*  ww  w  . ja v  a  2  s.  co m*/
public static Map<String, String> mapOf(final String... keyOrValues) {
    if (keyOrValues.length % 2 != 0) {
        throw new IllegalArgumentException("Must provide an even number of arguments");
    }
    final Map<String, String> map = Maps.newLinkedHashMap();
    String key = null;
    for (final String keyOrValue : keyOrValues) {
        if (key != null) {
            map.put(key, keyOrValue);
            key = null;
        } else {
            key = keyOrValue;
        }
    }
    return Collections.unmodifiableMap(map);
}

From source file:classes.Data.java

public Data() {
    values = Maps.newLinkedHashMap();
}

From source file:brooklyn.rest.transform.HighAvailabilityTransformer.java

public static HighAvailabilitySummary highAvailabilitySummary(String ownNodeId,
        ManagementPlaneSyncRecord memento) {
    Map<String, HaNodeSummary> nodes = Maps.newLinkedHashMap();
    for (Map.Entry<String, ManagementNodeSyncRecord> entry : memento.getManagementNodes().entrySet()) {
        nodes.put(entry.getKey(), haNodeSummary(entry.getValue()));
    }/*ww w .  j  ava  2 s .  co m*/

    // TODO What links?
    ImmutableMap.Builder<String, URI> lb = ImmutableMap.<String, URI>builder();

    return new HighAvailabilitySummary(ownNodeId, memento.getMasterNodeId(), nodes, lb.build());
}

From source file:com.netflix.metacat.common.partition.util.PartitionUtil.java

/**
 * Returns the partition key values from the given path.
 * @param location location path//from www .j ava  2  s.co  m
 * @return the partition key values from the given path.
 */
public static Map<String, String> getPartitionKeyValues(final String location) {
    final Map<String, String> parts = Maps.newLinkedHashMap();
    getPartitionKeyValues(location, parts);
    return parts;
}

From source file:org.sonatype.nexus.plugins.rrb.QueryStrings.java

/**
 * Parses a query-string into a map./*w  ww. j  av a2 s .c  o m*/
 *
 * @param input Query-string input ot parse; never null
 * @return  Ordered map of parsed query string parameters.
 */
public static Map<String, String> parse(final String input) {
    checkNotNull(input);
    Map<String, String> result = Maps.newLinkedHashMap();
    String[] fields = input.split(FIELD_SEPARATOR);
    for (String field : fields) {
        String key, value;
        int i = field.indexOf(VALUE_SEPARATOR);
        if (i == -1) {
            key = field;
            value = null;
        } else {
            key = field.substring(0, i);
            value = field.substring(i + 1, field.length());
        }
        result.put(key, value);
    }
    return result;
}

From source file:org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesUtil.java

public static Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> recreateTypeParametersAndReturnMapping(
        @NotNull List<TypeParameterDescriptor> originalParameters, @Nullable DeclarationDescriptor newOwner) {
    Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> result = Maps.newLinkedHashMap(); // save order of type parameters
    for (TypeParameterDescriptor typeParameter : originalParameters) {
        result.put(typeParameter,//from w w  w  .j a  v  a2 s  .  c om
                TypeParameterDescriptorImpl.createForFurtherModification(
                        newOwner == null ? typeParameter.getContainingDeclaration() : newOwner,
                        typeParameter.getAnnotations(), typeParameter.isReified(), typeParameter.getVariance(),
                        typeParameter.getName(), typeParameter.getIndex()));
    }
    return result;
}