public OddItemGroups(Map<String, Object> serialized) { aliases = new HashMap<OddItemGroup, Set<String>>(); groups = new TreeMap<String, OddItemGroup>(OddItem.ALPHANUM_COMPARATOR); for (String key : serialized.keySet()) { OddItemGroup group = OddItemGroup.valueOf(((ConfigurationSection) serialized.get(key)).getValues(false)); if (aliases.get(group) == null) aliases.put(group, new TreeSet<String>(OddItem.ALPHANUM_COMPARATOR)); aliases .get(group) .addAll(((ConfigurationSection) serialized.get(key)).getStringList("aliases")); aliases.get(group).add(key); for (String alias : aliases.get(group)) { groups.put(alias, group); } } }
/** * Checks for groups containing second-level data key * * @param key top-level key to check * @param key2 second-level key to check * @return Collection of groups containing keys */ public Collection<OddItemGroup> getGroups(String key, String key2) { Collection<OddItemGroup> groups = new HashSet<OddItemGroup>(); for (OddItemGroup group : this.groups.values()) if (group.match(key, key2)) groups.add(group); return groups; }