From 780a3da69b66921fb7bf7b5779fb44830bb45ddc Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Tue, 7 Apr 2020 21:21:12 -0400 Subject: Remove utils.esodata utils.esodata now also lives in the esodata project; not here --- base/src/main/java/bjc/utils/esodata/MapSet.java | 178 ----------------------- 1 file changed, 178 deletions(-) delete mode 100644 base/src/main/java/bjc/utils/esodata/MapSet.java (limited to 'base/src/main/java/bjc/utils/esodata/MapSet.java') diff --git a/base/src/main/java/bjc/utils/esodata/MapSet.java b/base/src/main/java/bjc/utils/esodata/MapSet.java deleted file mode 100644 index 16def9e..0000000 --- a/base/src/main/java/bjc/utils/esodata/MapSet.java +++ /dev/null @@ -1,178 +0,0 @@ -package bjc.utils.esodata; - -import java.util.AbstractMap; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * A string-keyed set of maps. - * - * @author bjculkin - * - * @param - * The key type of the maps. - * @param - * The value type of the maps. - */ -public class MapSet extends AbstractMap { - private Map> backing; - - private Map currentMap = null; - - /** - * Create a new set of maps. - */ - public MapSet() { - backing = new HashMap<>(); - } - - /** - * Create a new set of maps, with the specified set of maps. - * - * @param back - * The set of maps to use. - */ - public MapSet(Map> back) { - backing = back; - } - - /** - * Add a keyed map. - * - * @param key - * The key for the map. - * @param map - * The map itself. - */ - public void addMap(String key, Map map) { - backing.put(key, map); - } - - /** - * Clear out the contents of the set - */ - public void clearMap() { - currentMap = null; - - backing.clear(); - } - - /** - * Check if there is a map attached to the specified key. - * - * @param key - * The key to look for. - * @return Whether or not there is anything attached to the key. - */ - public boolean containsMap(String key) { - return backing.containsKey(key); - } - - /** - * Get the map attached to a specified key. - * - * @param key - * The key to look for. - * @return The map attached to the key. - */ - public Map getMap(String key) { - return backing.get(key); - } - - /** - * Get all of the backing entries. - * - * @return The backing entries. - */ - public Set>> getMapEntries() { - return backing.entrySet(); - } - - /** - * Get all of the keys. - * - * @return The keys currently in use. - */ - public Set getMapKeys() { - return backing.keySet(); - } - - /** - * Get all of the keyed maps. - * - * @return The keyed maps. - */ - public Collection> getMapValues() { - return backing.values(); - } - - /** - * Set the current map. - * - * @param key - * The key to use as the current map. - * @return False if there is no map attached to the key, true otherwise. - */ - public boolean setMap(String key) { - if (!backing.containsKey(key)) return false; - - currentMap = backing.get(key); - - return true; - } - - /** - * Sets the current map, or creates a new one if there isn't one - * attached to that key. - * - * @param key - * The key to use as the current map. - */ - public void setCreateMap(String key) { - if (!backing.containsKey(key)) { - currentMap = new HashMap<>(); - - backing.put(key, currentMap); - - return; - } - - currentMap = backing.get(key); - } - - /** - * Set the current map, or bind a map to it. - * - * @param key - * The key to set or bind. - * @param map - * The map to bind to the key if it isn't present. - */ - public void setPutMap(String key, Map map) { - if (!backing.containsKey(key)) { - currentMap = map; - - backing.put(key, map); - - return; - } - - currentMap = backing.get(key); - } - - @Override - public Set> entrySet() { - if (currentMap == null) throw new NullPointerException("Current map is not set"); - - return currentMap.entrySet(); - } - - @Override - public ValueType put(KeyType key, ValueType value) { - if (currentMap == null) throw new NullPointerException("Current map is not set"); - - return currentMap.put(key, value); - } -} -- cgit v1.2.3