MapDBContext implements DBContext { @Override public String info(String name) { Object struct = db.get(name); if (isNull(struct)) throw new IllegalStateException(format("DB structure with name [%s] does not exist", name)); if (struct instanceof Set) return format("%s - Set - %d", name, ((Set) struct).size()); else if (struct instanceof List) return format("%s - List - %d", name, ((List) struct).size()); else if (struct instanceof Map) return format("%s - Map - %d", name, ((Map) struct).size()); else return format("%s - %s", name, struct.getClass().getSimpleName()); } MapDBContext(DB db); static DBContext onlineInstance(String name); static DBContext offlineInstance(String name); @Override List<T> getList(String name); @Override Map<K, V> getMap(String name); @Override Set<T> getSet(String name); @Override Var<T> getVar(String name); @Override String summary(); @Override Object backup(); @Override boolean recover(Object backup); @Override String info(String name); @Override void commit(); @Override void clear(); @Override boolean contains(String name); @Override void close();  }
@Test void cantGetInfoFromNonexistentDBStructureName() { Assertions.assertThrows(IllegalStateException.class, () -> db.info(TEST)); }