package boil.library; import misc.*; import java.util.HashMap; public class TypeFactory { private int type_num; private HashMap map; public void reset() { this.type_num = 0; this.map = new HashMap<>(); } public String alias(String t) { /** * Given a TypeInstance, return the designated * vapor alias. If the alias does not exist, create it. */ String alias; if ((alias = this.map.get(t)) == null) { MinimalLogger.info(String.format("Creating new alias for %s...", t)); alias = String.format("t.%d", this.type_num++); this.map.put(t, alias); } return alias; } public String retrieveRecentList(int x) { /** * Given int x, retrieve a space-delimited * list of the x most recent entries. */ String rtn = ""; if (x > 0) { rtn += String.format("t.%d", type_num-x); for (int i = type_num-(x-1); i < type_num; ++i) { rtn += String.format(" t.%d", i); } } return rtn; } }