public AgeSet getAgeSet(Region region, int index) { AgeSet ageSet = ageMap.get(region, index); if ((ageSet == null) || !ageSet.hasBonuses()) { ageSet = ageMap.get(Region.getConstant("None"), index); } return ageSet; }
@Override public String toString() { final StringBuilder sb = new StringBuilder(100); sb.append("AgeMap: ").append(ageMap.toString()).append("\n"); sb.append("UserMap: ").append(userMap.toString()).append("\n"); return sb.toString(); }
public AgeSet addToAgeMap(String regionName, AgeSet ageSet, URI sourceURI) { AgeSet old = ageMap.get(Region.getConstant(regionName), ageSet.getIndex()); if (old != null) { if (ageSet.hasBonuses() || !ageSet.getKits().isEmpty() || !ageSet.getName().equals(old.getName())) { Logging.errorPrint( "Found second (non-identical) AGESET " + "in Bio Settings " + sourceURI + " for Region: " + regionName + " Index: " + ageSet.getIndex() + " using the existing " + old.getLSTformat()); } return old; } ageMap.put(Region.getConstant(regionName), ageSet.getIndex(), ageSet); return ageSet; }
private String appendAgesetInfo( Region region, final SortedMap<Integer, SortedMap<String, SortedMap<String, String>>> ageSets, final StringBuilder sb) { Set<Integer> ageIndices = new TreeSet<Integer>(); ageIndices.addAll(ageSets.keySet()); ageIndices.addAll(ageNames.values()); // Iterate through ages, outputing the info for (Integer key : ageIndices) { final SortedMap<String, SortedMap<String, String>> races = ageSets.get(key); if (races == null) { continue; } sb.append("AGESET:"); sb.append(ageMap.get(region, key).getLSTformat()).append("\n"); for (Iterator<String> raceIt = races.keySet().iterator(); raceIt.hasNext(); ) { final String aRaceName = raceIt.next(); if (!"AGESET".equals(aRaceName)) { final SortedMap<String, String> tags = races.get(aRaceName); for (Iterator<String> tagIt = tags.keySet().iterator(); tagIt.hasNext(); ) { final String tagName = tagIt.next(); sb.append("RACENAME:").append(aRaceName).append("\t\t"); sb.append(tagName).append(':').append(tags.get(tagName)).append("\n"); } } } sb.append("\n"); } return sb.toString(); }
public Map<Integer, AgeSet> getAgeSets(String regionName) { return new TreeMap<Integer, AgeSet>(ageMap.getMapFor(Region.getConstant(regionName))); }
/** * Copies the key/value combinations from the given MapKeyMap into this MapKeyMap. If this * MapKeyMap already contained a mapping for the any of the key combinations in the given * MapKeyMap, the previous value is overwritten. * * @param mkm The MapKeyMap for which the key/value combinations should be placed into this * MapKeyMap * @throws NullPointerException if the given MapKeyMap is null */ public final void putAll(MapKeyMap mkm) { map.putAll(mkm.map); }
/** * Adds the given value to the List for the given ListKey. The null value cannot be used as a key * in a MapKeyMap. This method will automatically initialize the map for the given primary key if * there is not already a Map for that primary key. * * <p>This method is reference-semantic and this MapKeyMap will maintain a strong reference to * both the key object and the value object given as arguments to this method. * * @param key1 The MapKey indicating which Map the given object should be added to. * @param value The value to be added to the List for the given key. */ public <K, V> V addToMapFor(MapKey<K, V> key1, K key2, V value) { return (V) map.put(key1, key2, value); }
/** * Returns the consistent-with-equals hashCode for this MapKeyMap. * * @return the int * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return map.hashCode(); }
/** * Returns true if this MapKeyMap is equal to the given Object. * * <p>Note that equality as defined by this method is both a class of MapKeyMap and equality of * contents of the MapKeyMap. * * @param obj the o * @return true, if equals * @see java.lang.Object#equals() */ @Override public boolean equals(Object obj) { return obj instanceof MapKeyMap && map.equals(((MapKeyMap) obj).map); }
/** * Removes the List for the given ListKey. Note there is no requirement that the list for the * given key be empty before this method is called. * * <p>Ownership of the returned Map is transferred to the object calling this method. * * @return The Map which this MapKeyMap previous mapped the given key */ public <K, V> Map<K, V> removeMapFor(MapKey<K, V> key) { return map.removeAll(key); }
/** * Returns a Set indicating the Keys of this MapKeyMap. Ownership of the Set is transferred to the * calling Object, no association is kept between the Set and this MapKeyMap. (Thus, removal of a * key from the returned Set will not remove that key from this MapKeyMap) * * <p>NOTE: This method returns all of the keys this MapKeyMap contains. It DOES NOT determine * whether the Lists defined for the keys are empty. Therefore, it is possible that this MapKeyMap * contains one or more keys, and all of the lists associated with those keys are empty, yet this * method will return a non-zero length Set. * * @return a Set containing the keys in this MapKeyMap */ public Set<MapKey<?, ?>> getKeySet() { return map.getKeySet(); }
/** * Removes the given value from the map for the given MapKey. Returns true if the value was * successfully removed from the map for the given MapKey. Returns false if there is not a map for * the given MapKey or if the map for the given MapKey did not contain the given secondary key. * * @param key1 The MapKey indicating which Map the given object should be removed from * @param key2 The key to be removed from the Map * @return true if the key and its associated value were successfully removed from the map; false * otherwise */ public <K, V> boolean removeFromMapFor(MapKey<K, V> key1, K key2) { return map.remove(key1, key2) != null; }
/** * Returns a Set of the secondary keys for the given primary key in this MapKeyMap. This method * returns an empty set if the given key is not in this MapKeyMap. * * <p>Note: This Set is reference-semantic. The ownership of the Set is transferred to the calling * Object; therefore, changes to the returned Set will NOT impact the MapKeyMap. * * @param key The MapKey for which a copy of the keys should be returned. * @return A <tt>Set</tt> of secondary key objects for the given primary key. */ public <K, V> Set<K> getKeysFor(MapKey<K, V> key1) { return map.getSecondaryKeySet(key1); }
/** * Returns a copy of the List contained in this MapKeyMap for the given ListKey. This method * returns null if the given key is not in this MapKeyMap. * * <p>This method is value-semantic in that no changes are made to the object passed into the * method and ownership of the returned List is transferred to the class calling this method. * * @param key The ListKey for which a copy of the list should be returned. * @return a copy of the List contained in this MapKeyMap for the given key; null if the given key * is not a key in this MapKeyMap. */ public <K, V> Map<K, V> getMapFor(MapKey<K, V> key1) { return map.getMapFor(key1); }
/** * Returns a copy of the List contained in this MapKeyMap for the given ListKey. This method * returns null if the given key is not in this MapKeyMap. * * <p>This method is value-semantic in that no changes are made to the object passed into the * method and ownership of the returned List is transferred to the class calling this method. * * @param key The ListKey for which a copy of the list should be returned. * @return a copy of the List contained in this MapKeyMap for the given key; null if the given key * is not a key in this MapKeyMap. */ public <K, V> V get(MapKey<K, V> key1, K key2) { return (V) map.get(key1, key2); }
/** * Returns true if this MapKeyMap contains a Map for the given MapKey. This method returns false * if the given key is not in this MapKeyMap. * * <p>This method is value-semantic in that no changes are made to the object passed into the * method. * * @param key The MapKey being tested. * @return true if this MapKeyMap contains a Map for the given key; false otherwise. */ public boolean containsMapFor(MapKey<?, ?> key) { return map.containsKey(key); }