@Test public void putTest() { for (int tileSize : TILE_SIZES) { TileCache tileCache = new InMemoryTileCache(0); verifyInvalidPut(tileCache, null, GRAPHIC_FACTORY.createTileBitmap(tileSize, true)); verifyInvalidPut(tileCache, new DownloadJob(new Tile(0, 0, (byte) 0), tileSize, OpenStreetMapMapnik.INSTANCE), null); } }
@Override public synchronized void put(Job key, TileBitmap bitmap) { if (key == null) { throw new IllegalArgumentException("key must not be null"); } else if (bitmap == null) { throw new IllegalArgumentException("bitmap must not be null"); } TileBitmap old = this.lruCache.get(key); if (old != null) { old.decrementRefCount(); } if (this.lruCache.put(key, bitmap) != null) { LOGGER.warning("overwriting cached entry: " + key); } bitmap.incrementRefCount(); }
InMemoryTileCache implements TileCache { @Override public synchronized void put(Job key, TileBitmap bitmap) { if (key == null) { throw new IllegalArgumentException("key must not be null"); } else if (bitmap == null) { throw new IllegalArgumentException("bitmap must not be null"); } TileBitmap old = this.lruCache.get(key); if (old != null) { old.decrementRefCount(); } if (this.lruCache.put(key, bitmap) != null) { LOGGER.warning("overwriting cached entry: " + key); } bitmap.incrementRefCount(); } }
InMemoryTileCache implements TileCache { @Override public synchronized void put(Job key, TileBitmap bitmap) { if (key == null) { throw new IllegalArgumentException("key must not be null"); } else if (bitmap == null) { throw new IllegalArgumentException("bitmap must not be null"); } TileBitmap old = this.lruCache.get(key); if (old != null) { old.decrementRefCount(); } if (this.lruCache.put(key, bitmap) != null) { LOGGER.warning("overwriting cached entry: " + key); } bitmap.incrementRefCount(); } InMemoryTileCache(int capacity); }
InMemoryTileCache implements TileCache { @Override public synchronized void put(Job key, TileBitmap bitmap) { if (key == null) { throw new IllegalArgumentException("key must not be null"); } else if (bitmap == null) { throw new IllegalArgumentException("bitmap must not be null"); } TileBitmap old = this.lruCache.get(key); if (old != null) { old.decrementRefCount(); } if (this.lruCache.put(key, bitmap) != null) { LOGGER.warning("overwriting cached entry: " + key); } bitmap.incrementRefCount(); } InMemoryTileCache(int capacity); @Override synchronized boolean containsKey(Job key); @Override synchronized void destroy(); @Override synchronized TileBitmap get(Job key); @Override synchronized int getCapacity(); @Override synchronized void put(Job key, TileBitmap bitmap); synchronized void setCapacity(int capacity); }
InMemoryTileCache implements TileCache { @Override public synchronized void put(Job key, TileBitmap bitmap) { if (key == null) { throw new IllegalArgumentException("key must not be null"); } else if (bitmap == null) { throw new IllegalArgumentException("bitmap must not be null"); } TileBitmap old = this.lruCache.get(key); if (old != null) { old.decrementRefCount(); } if (this.lruCache.put(key, bitmap) != null) { LOGGER.warning("overwriting cached entry: " + key); } bitmap.incrementRefCount(); } InMemoryTileCache(int capacity); @Override synchronized boolean containsKey(Job key); @Override synchronized void destroy(); @Override synchronized TileBitmap get(Job key); @Override synchronized int getCapacity(); @Override synchronized void put(Job key, TileBitmap bitmap); synchronized void setCapacity(int capacity);  }