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:de.tu_berlin.dima.oligos.db.HistogramHandler.java

@Override
public Map<T, Long> handle(ResultSet rs) throws SQLException {
    Map<T, Long> mostFrequentValues = Maps.newLinkedHashMap();
    while (rs.next()) {
        String colvalue = (keyColumnName != null) ? rs.getString(keyColumnName) : rs.getString(keyColumnIndex);
        if (colvalue != null) {
            T value = parser.fromString(colvalue.replaceAll("'", ""));
            long count = (valColumnName != null) ? rs.getLong(valColumnName) : rs.getLong(valColumnIndex);
            mostFrequentValues.put(value, count);
        }// ww  w  .  j  a  va2s.  com
    }
    return mostFrequentValues;
}

From source file:de.cosmocode.json.JSON.java

/**
 * Creates a {@link JSONObject} based on a
 * {@link LinkedHashMap} which provides insertion
 * order.// ww  w.  ja  v a2  s  . co m
 * 
 * @return a new {@link JSONObject} based on a {@link LinkedHashMap}
 */
public static JSONObject createLinkedJSONObject() {
    final Map<Object, Object> map = Maps.newLinkedHashMap();
    return new JSONObject(map);
}

From source file:org.apache.brooklyn.test.EntityTestUtils.java

public static <T> void assertAttributeEqualsEventually(final Entity entity, final AttributeSensor<T> attribute,
        final T expected) {
    assertAttributeEqualsEventually(Maps.newLinkedHashMap(), entity, attribute, expected);
}

From source file:org.cinchapi.concourse.server.storage.db.BrowsableRecord.java

/**
 * Return a view of all the data that is presently contained in this record.
 * /*from  w  w  w .j  av  a  2  s  .c om*/
 * @return the data
 */
public Map<K, Set<V>> browse() {
    read.lock();
    try {
        Map<K, Set<V>> data = Maps.newLinkedHashMap();
        for (K key : describe()) {
            data.put(key, get(key));
        }
        return data;
    } finally {
        read.unlock();
    }

}

From source file:com.dtstack.jlogstash.factory.OutputFactory.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public static List<BaseOutput> getBatchInstance(List<Map> outputs) throws Exception {
    if (outputs == null || outputs.size() == 0)
        return null;
    List<BaseOutput> baseoutputs = Lists.newArrayList();
    for (int i = 0; i < outputs.size(); i++) {
        Iterator<Entry<String, Map>> outputIT = outputs.get(i).entrySet().iterator();
        while (outputIT.hasNext()) {
            Map.Entry<String, Map> outputEntry = outputIT.next();
            String outputType = outputEntry.getKey();
            Map outputConfig = outputEntry.getValue();
            String className = getClassName(outputType, PLUGINTYPE);
            String key = String.format("%s%d", className, i);
            Class<?> outputClass = outputsClassLoader.get(key);
            if (outputClass == null) {
                outputClass = getPluginClass(outputType, PLUGINTYPE, className);
                outputsClassLoader.put(key, outputClass);
            }/*from  ww  w  . j av  a2s.  c o  m*/
            if (outputConfig == null)
                outputConfig = Maps.newLinkedHashMap();
            baseoutputs.add(getInstance(outputType, outputConfig, outputClass));
        }
    }
    return baseoutputs;
}

From source file:com.github.autermann.matlab.MatlabRequest.java

/**
 * Creates a new <code>MLRequest</code> instance for the given function
 * name. This constructor will assume/*from  ww w .j a  v  a 2 s  .  c  o m*/
 * you are only expecting/requesting a single result value - use
 * {@link #MLRequest(String, int)} or
 * {@link #setResultCount(int)} if you wish for more.
 *
 * @param function the name of the function to execute
 */
public MatlabRequest(String function) {
    checkArgument(function != null && !function.isEmpty());
    this.function = function;
    this.results = Maps.newLinkedHashMap();
    this.parameters = Lists.newLinkedList();
}

From source file:de.matzefratze123.heavyspleef.core.FlagManager.java

public FlagManager(JavaPlugin plugin, GamePropertyBundle defaults) {
    this.plugin = plugin;
    this.defaults = defaults;
    this.flags = Maps.newLinkedHashMap();
    this.propertyBundles = Sets.newTreeSet();
    this.requestedProperties = new DefaultGamePropertyBundle(Maps.newEnumMap(GameProperty.class));
}

From source file:com.yahoo.yqlplus.engine.rules.MergeFilters.java

private OperatorNode<SequenceOperator> visitChain(OperatorNode<SequenceOperator> top,
        OperatorNode<SequenceOperator> current) {
    if (MERGE_THROUGH.contains(current.getOperator())) {
        return visitChain(top, (OperatorNode<SequenceOperator>) current.getArgument(0));
    } else if (top == current) {
        return top;
    } else {/*from  w w  w. jav a 2 s .  co  m*/
        // if there's any sorting, we'd like to do it AFTER we filter
        // 'current' contains what will be the target of the new filter (as it is neither FILTER or SORT)
        // we know 'top' is a FILTER because it started as such
        // so, walk between top and current, accumulating filters and sorting
        Deque<OperatorNode<SequenceOperator>> sorts = Lists.newLinkedList();
        List<OperatorNode<ExpressionOperator>> filters = Lists.newArrayList();
        Map<String, Object> annotations = Maps.newLinkedHashMap();
        OperatorNode<SequenceOperator> n = top;
        while (n != current) {
            if (n.getOperator() == SequenceOperator.FILTER) {
                annotations.putAll(n.getAnnotations());
                filters.add(super.visitExpr((OperatorNode<ExpressionOperator>) n.getArgument(1)));
                n = n.getArgument(0);
            } else if (n.getOperator() == SequenceOperator.SORT) {
                sorts.addFirst(n);
            }
        }
        current = super.visitSequenceOperator(current);
        OperatorNode<ExpressionOperator> filter = createFilter(filters);
        OperatorNode<SequenceOperator> filtered = OperatorNode.create(top.getLocation(), annotations,
                SequenceOperator.FILTER, current, filter);
        while (!sorts.isEmpty()) {
            OperatorNode<SequenceOperator> sort = sorts.removeLast();
            filtered = OperatorNode.create(sort.getLocation(), sort.getAnnotations(), sort.getOperator(),
                    filtered, sort.getArgument(1));
        }
        return filtered;
    }
}

From source file:org.apache.brooklyn.core.location.AggregatingMachineProvisioningLocation.java

public AggregatingMachineProvisioningLocation() {
    this(Maps.newLinkedHashMap());
}

From source file:com.dtstack.jlogstash.factory.FilterFactory.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public static List<BaseFilter> getBatchInstance(List<Map> filters) throws Exception {
    if (filters == null || filters.size() == 0)
        return null;
    List<BaseFilter> baseFilters = Lists.newArrayList();
    for (int i = 0; i < filters.size(); i++) {
        Iterator<Entry<String, Map>> filterIT = filters.get(i).entrySet().iterator();
        while (filterIT.hasNext()) {
            Map.Entry<String, Map> filterEntry = filterIT.next();
            String filterType = filterEntry.getKey();
            Map filterConfig = filterEntry.getValue();
            String className = getClassName(filterType, PLUGINTYPE);
            String key = String.format("%s%d", className, i);
            Class<?> filterClass = filtersClassLoader.get(key);
            if (filterClass == null) {
                filterClass = getPluginClass(filterType, PLUGINTYPE, className);
                filtersClassLoader.put(key, filterClass);
            }/*from www  . j  a va 2s.c om*/
            if (filterConfig == null)
                filterConfig = Maps.newLinkedHashMap();
            baseFilters.add(getInstance(filterType, filterConfig, filterClass));
        }
    }
    return baseFilters;
}