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

/**
 * Creates a case-insensitive map.//from w w  w  .j a  va2 s .  c  o  m
 *
 * @param <T>
 * The object type of the map
 * @return An empty case-insensitive map
 */
public static <T> SortedMap<String, T> newCaseInsensitiveMap() {
    TreeMap<String, T> rv = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    return rv;
}

From source file:fr.ribesg.bukkit.ncore.updater.FileDescription.java

public static SortedMap<String, FileDescription> parse(final String jsonString) {
    final SortedMap<String, FileDescription> result = new TreeMap<>(new Comparator<String>() {

        @Override//from   w ww.j  a  va2  s  .c  o m
        public int compare(final String a, final String b) {
            return -a.compareTo(b);
        }
    });
    final JSONArray array = (JSONArray) JSONValue.parse(jsonString);
    for (final Object o : array.toArray()) {
        final JSONObject object = (JSONObject) o;
        final String fileName = (String) object.get(FILENAME_KEY);
        final String version = VersionUtil.getVersion((String) object.get(VERSION_KEY));
        final String bukkitVersion = (String) object.get(BUKKIT_VERSION_KEY);
        final String type = (String) object.get(TYPE_KEY);
        final String link = (String) object.get(DOWNLOAD_URL_KEY);
        final FileDescription fileDescription = new FileDescription(fileName, version, link, type,
                bukkitVersion);
        if (VersionUtil.isRelease(version)) {
            result.put(version, fileDescription);
        }
    }
    return result;
}

From source file:jease.cms.service.Informatons.java

public static Map<Class<?>, Integer> getDatabaseClassCount() {
    Map<Class<?>, Integer> resultMap = new TreeMap<>(Comparator.comparing(Class::getName));
    for (Persistent obj : Database.query(Persistent.class)) {
        Class<?> clazz = obj.getClass();
        if (!resultMap.containsKey(clazz)) {
            resultMap.put(clazz, 0);/*from   w  w w  .j a  va  2s  .c  o m*/
        }
        resultMap.put(clazz, resultMap.get(clazz) + 1);
    }
    return resultMap;
}

From source file:io.wcm.caravan.commons.httpclient.impl.BeanUtil.java

/**
 * Get map with key/value pairs for properties of a java bean (using {@link BeanUtils#describe(Object)}).
 * An array of property names can be passed that should be masked with "***" because they contain sensitive
 * information.// w  w  w. j av a2 s .  com
 * @param beanObject Bean object
 * @param maskProperties List of property names
 * @return Map with masked key/value pairs
 */
public static SortedMap<String, Object> getMaskedBeanProperties(Object beanObject, String[] maskProperties) {
    try {
        SortedMap<String, Object> configProperties = new TreeMap<String, Object>(
                BeanUtils.describe(beanObject));

        // always ignore "class" properties which is added by BeanUtils.describe by default
        configProperties.remove("class");

        // Mask some properties with confidential information (if set to any value)
        if (maskProperties != null) {
            for (String propertyName : maskProperties) {
                if (configProperties.containsKey(propertyName) && configProperties.get(propertyName) != null) {
                    configProperties.put(propertyName, "***");
                }
            }
        }

        return configProperties;
    } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
        throw new IllegalArgumentException("Unable to get properties from: " + beanObject, ex);
    }
}

From source file:io.github.swagger2markup.internal.utils.TagUtils.java

/**
 * Converts the global Tag list into a Map where the tag name is the key and the Tag the value.
 * Either ordered or as-is, if the comparator is null.
 *
 * @param tags       the List of tags/*from ww  w. j a  v a2  s  .  c o  m*/
 * @param comparator the comparator to use.
 * @return the Map of tags. Either ordered or as-is, if the comparator is null.
 */
public static Map<String, Tag> toSortedMap(List<Tag> tags, Comparator<String> comparator) {
    Map<String, Tag> sortedMap;
    if (comparator == null)
        sortedMap = new LinkedHashMap<>();
    else
        sortedMap = new TreeMap<>(comparator);
    tags.forEach(tag -> sortedMap.put(tag.getName(), tag));
    return sortedMap;
}

From source file:com.mac.holdempoker.app.hands.Boat.java

public Boat() {
    super(HandType.FULL_HOUSE);
    cards = new TreeMap(this);
}

From source file:com.mac.holdempoker.app.hands.TwoPair.java

public TwoPair() {
    super(HandType.TWO_PAIR);
    cards = new TreeMap(this);
}

From source file:com.mac.holdempoker.app.hands.Pair.java

public Pair() {
    super(HandType.PAIR);
    cards = new TreeMap(this);
}

From source file:com.mac.holdempoker.app.hands.Set.java

public Set() {
    super(HandType.THREE_OF_A_KIND);
    cards = new TreeMap(this);
}

From source file:com.mac.holdempoker.app.hands.Quad.java

public Quad() {
    super(HandType.FOUR_OF_A_KIND);
    cards = new TreeMap(this);
}