@Test public void testRemove() throws IOException { File colorsFile = File.createTempFile("colors", "j81"); colorsFile.deleteOnExit(); PersistentMap colors = new PersistentMap(colorsFile); colors.put("red", chunkify(Color.red)); colors.put("orange", chunkify(Color.orange)); colors.put("sunny", chunkify(Color.yellow)); colors.put("vert", chunkify(Color.green)); colors.put("blue", chunkify(Color.blue)); colors.put("grape", chunkify(Color.magenta.darker())); colors.put("white", chunkify(Color.white)); colors.put("medium", chunkify(Color.gray)); colors.put("dark", chunkify(Color.black)); colors.remove("red"); colors.remove("white"); colors.remove("blue"); colors.close(); colors = new PersistentMap(colorsFile); assertNull(colors.get("red")); assertEquals(deChunkify((Chunk)colors.get("orange")), Color.orange); assertEquals(deChunkify((Chunk)colors.get("sunny")), Color.yellow); assertEquals(deChunkify((Chunk)colors.get("vert")), Color.green); assertNull(colors.get("blue")); assertEquals(deChunkify((Chunk)colors.get("grape")), Color.magenta.darker()); assertNull(colors.get("white")); assertEquals(deChunkify((Chunk)colors.get("medium")), Color.gray); assertEquals(deChunkify((Chunk)colors.get("dark")), Color.black); assertNull(colors.get("turquoise")); assertNull(colors.get("creme")); assertNull(colors.get("lavender")); colors.remove("sunny"); colors.remove("dark"); assertNull(colors.get("red")); assertEquals(deChunkify((Chunk)colors.get("orange")), Color.orange); assertNull(colors.get("sunny")); assertEquals(deChunkify((Chunk)colors.get("vert")), Color.green); assertNull(colors.get("blue")); assertEquals(deChunkify((Chunk)colors.get("grape")), Color.magenta.darker()); assertNull(colors.get("white")); assertEquals(deChunkify((Chunk)colors.get("medium")), Color.gray); assertNull(colors.get("dark")); assertNull(colors.get("turquoise")); assertNull(colors.get("creme")); assertNull(colors.get("lavender")); colors.close(); colors = new PersistentMap(colorsFile); assertNull(colors.get("red")); assertEquals(deChunkify((Chunk)colors.get("orange")), Color.orange); assertNull(colors.get("sunny")); assertEquals(deChunkify((Chunk)colors.get("vert")), Color.green); assertNull(colors.get("blue")); assertEquals(deChunkify((Chunk)colors.get("grape")), Color.magenta.darker()); assertNull(colors.get("white")); assertEquals(deChunkify((Chunk)colors.get("medium")), Color.gray); assertNull(colors.get("dark")); assertNull(colors.get("turquoise")); assertNull(colors.get("creme")); assertNull(colors.get("lavender")); }
@Override public Object remove(Object key) { Chunk removed = (Chunk)map.remove(key); if(removed == null) return null; nioDaemon.invokeLater(new RemoveChunk(this, removed)); return removed; }
PersistentMap implements Map { @Override public Object remove(Object key) { Chunk removed = (Chunk)map.remove(key); if(removed == null) return null; nioDaemon.invokeLater(new RemoveChunk(this, removed)); return removed; } }
PersistentMap implements Map { @Override public Object remove(Object key) { Chunk removed = (Chunk)map.remove(key); if(removed == null) return null; nioDaemon.invokeLater(new RemoveChunk(this, removed)); return removed; } PersistentMap(File file);  PersistentMap(File file, ByteCoder keyCoder); }
PersistentMap implements Map { @Override public Object remove(Object key) { Chunk removed = (Chunk)map.remove(key); if(removed == null) return null; nioDaemon.invokeLater(new RemoveChunk(this, removed)); return removed; } PersistentMap(File file);  PersistentMap(File file, ByteCoder keyCoder); void close(); void flush(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override Set entrySet(); @Override Object put(Object key, Object value); @Override Object get(Object key); @Override Object remove(Object key); @Override Set keySet(); @Override Collection values(); @Override boolean isEmpty(); @Override void putAll(Map m); @Override int size(); }
PersistentMap implements Map { @Override public Object remove(Object key) { Chunk removed = (Chunk)map.remove(key); if(removed == null) return null; nioDaemon.invokeLater(new RemoveChunk(this, removed)); return removed; } PersistentMap(File file);  PersistentMap(File file, ByteCoder keyCoder); void close(); void flush(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override Set entrySet(); @Override Object put(Object key, Object value); @Override Object get(Object key); @Override Object remove(Object key); @Override Set keySet(); @Override Collection values(); @Override boolean isEmpty(); @Override void putAll(Map m); @Override int size();  }