@Override public Cache create(final String id) { Assert.notEmpty(id, "id"); if (this.contains(id)) { throw new IllegalArgumentException("A cache with name " + id + " already exists"); } Cache c = new MemoryCacheImpl(id); this.caches.add(c); return c; }
@Override public Cache get(final String id) { Assert.notEmpty(id, "id"); for (Cache cache : this.caches) { if (((MemoryCacheImpl) cache).getId().equals(id)) { return cache; } } return null; }
@Override public void remove(final String id) { Assert.notEmpty(id, "id"); Iterator<Cache> iterator = this.caches.iterator(); while (iterator.hasNext()) { Cache cache = iterator.next(); if (((MemoryCacheImpl) cache).getId().equals(id)) { iterator.remove(); break; } } }
@Override public boolean contains(final String id) { Assert.notEmpty(id, "id"); boolean b = false; for (Cache cache : this.caches) { if (((MemoryCacheImpl) cache).getId().equals(id)) { b = true; break; } } return b; }