@Test public void should_not_get_element_wth_media_type() { ResourceCache cache = new ResourceCache(); assertNull(cache.get("url", ResourceCache.class, MediaType.TEXT_HTML_TYPE)); }
@SuppressWarnings("unchecked") public <T> T get(String url, Class<T> clazz) { Serializable cacheKey = key(url, clazz); if (cache.isKeyInCache(cacheKey)) { Element element = cache.get(cacheKey); if (element != null) { Object objectValue = element.getObjectValue(); return (T) objectValue; } } return null; }
ResourceCache { @SuppressWarnings("unchecked") public <T> T get(String url, Class<T> clazz) { Serializable cacheKey = key(url, clazz); if (cache.isKeyInCache(cacheKey)) { Element element = cache.get(cacheKey); if (element != null) { Object objectValue = element.getObjectValue(); return (T) objectValue; } } return null; } }
ResourceCache { @SuppressWarnings("unchecked") public <T> T get(String url, Class<T> clazz) { Serializable cacheKey = key(url, clazz); if (cache.isKeyInCache(cacheKey)) { Element element = cache.get(cacheKey); if (element != null) { Object objectValue = element.getObjectValue(); return (T) objectValue; } } return null; } ResourceCache(); }
ResourceCache { @SuppressWarnings("unchecked") public <T> T get(String url, Class<T> clazz) { Serializable cacheKey = key(url, clazz); if (cache.isKeyInCache(cacheKey)) { Element element = cache.get(cacheKey); if (element != null) { Object objectValue = element.getObjectValue(); return (T) objectValue; } } return null; } ResourceCache(); @SuppressWarnings("unchecked") T get(String url, Class<T> clazz); @SuppressWarnings("unchecked") T get(String url, Class<T> clazz, MediaType mediaType); void put(T object, String url, Class<T> clazz); void put(T object, String url, Class<T> clazz, MediaType mediaType); }
ResourceCache { @SuppressWarnings("unchecked") public <T> T get(String url, Class<T> clazz) { Serializable cacheKey = key(url, clazz); if (cache.isKeyInCache(cacheKey)) { Element element = cache.get(cacheKey); if (element != null) { Object objectValue = element.getObjectValue(); return (T) objectValue; } } return null; } ResourceCache(); @SuppressWarnings("unchecked") T get(String url, Class<T> clazz); @SuppressWarnings("unchecked") T get(String url, Class<T> clazz, MediaType mediaType); void put(T object, String url, Class<T> clazz); void put(T object, String url, Class<T> clazz, MediaType mediaType);  }