Example usage for java.util TreeMap TreeMap

List of usage examples for java.util TreeMap TreeMap

Introduction

In this page you can find the example usage for java.util TreeMap TreeMap.

Prototype

public TreeMap(SortedMap<K, ? extends V> m) 

Source Link

Document

Constructs a new tree map containing the same mappings and using the same ordering as the specified sorted map.

Usage

From source file:Main.java

public static <K, V> TreeMap<K, V> createTreeMap(Map<? extends K, ? extends V> map) {
    if (map == null) {
        return null;
    }//w w w.j  a va2 s .c om

    return new TreeMap<K, V>(map);
}

From source file:Main.java

public static <K, V> TreeMap<K, V> createTreeMap(SortedMap<K, ? extends V> map) {
    if (map == null) {
        return null;
    }// ww  w  . ja  v  a2  s.c om

    return new TreeMap<K, V>(map);
}

From source file:Main.java

public static <K, V> TreeMap<K, V> createTreeMap(Comparator<? super K> comparator) {
    return new TreeMap<K, V>(comparator);
}

From source file:Main.java

public static <K, V> TreeMap<K, V> newTreeMap(final Comparator<? super K> c) {
    return new TreeMap<K, V>(c);
}

From source file:Main.java

public static Collection<Object> getSortedValues(Map<Integer, Object> vParameters) {
    if (vParameters == null || vParameters.size() == 0)
        return null;
    Set<Integer> keys = vParameters.keySet();

    SortedMap<Integer, Object> sortedMap = new TreeMap<Integer, Object>(vParameters);
    Collection<Object> result = sortedMap.values();
    return result;
}

From source file:Main.java

public static <K, V> TreeMap<K, V> newTreeMap(final Map<? extends K, ? extends V> m) {
    return new TreeMap<K, V>(m);
}

From source file:Main.java

static <K, V> Map<K, V> getMap(Map<K, V> orig) {
    if (orig == null || orig.size() == 0) {
        return Collections.emptyMap();
    } else if (orig.size() == 1) {
        final Map.Entry<K, V> entry = orig.entrySet().iterator().next();
        return Collections.singletonMap(entry.getKey(), entry.getValue());
    } else {/*ww w  .j av a  2  s  .  c  o  m*/
        return Collections.unmodifiableMap(new TreeMap<>(orig));
    }
}

From source file:Main.java

public static <K, V> TreeMap<K, V> newTreeMap(final SortedMap<K, ? extends V> m) {
    return new TreeMap<K, V>(m);
}

From source file:com.roncoo.utils.MerchantApiUtil.java

/**
 * ????/*  w w w.  j  a  v a2s  .co  m*/
 * @param paramMap  ???
 * @param paySecret ??
 * @return
 */
public static String getSign(Map<String, Object> paramMap, String paySecret) {
    SortedMap<String, Object> smap = new TreeMap<String, Object>(paramMap);
    StringBuffer stringBuffer = new StringBuffer();
    for (Map.Entry<String, Object> m : smap.entrySet()) {
        Object value = m.getValue();
        if (value != null && StringUtils.isNotBlank(String.valueOf(value))) {
            stringBuffer.append(m.getKey()).append("=").append(m.getValue()).append("&");
        }
    }
    stringBuffer.delete(stringBuffer.length() - 1, stringBuffer.length());

    String argPreSign = stringBuffer.append("&paySecret=").append(paySecret).toString();
    String signStr = MD5Util.encode(argPreSign).toUpperCase();

    return signStr;
}

From source file:com.roncoo.pay.trade.utils.MerchantApiUtil.java

/**
 * ????/* ww  w .j  a  v  a  2s  .  com*/
 * @param paramMap  ???
 * @param paySecret ??
 * @return
 */
public static String getSign(Map<String, Object> paramMap, String paySecret) {
    SortedMap<String, Object> smap = new TreeMap<String, Object>(paramMap);
    StringBuffer stringBuffer = new StringBuffer();
    for (Map.Entry<String, Object> m : smap.entrySet()) {
        Object value = m.getValue();
        if (value != null && StringUtils.isNotBlank(String.valueOf(value))) {
            stringBuffer.append(m.getKey()).append("=").append(value).append("&");
        }
    }
    stringBuffer.delete(stringBuffer.length() - 1, stringBuffer.length());

    String argPreSign = stringBuffer.append("&paySecret=").append(paySecret).toString();
    String signStr = MD5Util.encode(argPreSign).toUpperCase();

    return signStr;
}