@SuppressWarnings("unchecked") public <T> T get(Object key, Class<T> type) { Object value = fromStoreValue(lookup(key)); if (type != null && value != null && !type.isInstance(value)) { throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value); } return (T) value; }
@SuppressWarnings("unchecked") public <T> T get(Object key, Class<T> type) { Object value = fromStoreValue(lookup(key)); if (type != null && value != null && !type.isInstance(value)) { throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value); } return (T) value; }
@SuppressWarnings("unchecked") public <T> T get(Object key, Class<T> type) { Object value = fromStoreValue(lookup(key)); if (type != null && value != null && !type.isInstance(value)) { throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value); } return (T) value; }
@Override public ValueWrapper get(Object key) { if (key == null) { return null; } Object value = lookup(key); return value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null; }
@Override public ValueWrapper get(Object key) { if (key == null) { return null; } Object value = lookup(key); return value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null; }
@Override public ValueWrapper get(Object key) { if (key == null) { return null; } Object value = lookup(key); return value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null; }
public ValueWrapper putIfAbsent(Object key, Object value) { Object result = map.putIfAbsent(key, toStoreValue(value)); return result != null ? new SimpleValueWrapper(fromStoreValue(result)) : null; }
public ValueWrapper putIfAbsent(Object key, Object value) { Object result = map.putIfAbsent(key, toStoreValue(value)); return result != null ? new SimpleValueWrapper(fromStoreValue(result)) : null; }
@SuppressWarnings("unchecked") public <T> T get(Object key, Callable<T> valueLoader) { Object value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { this.map.lock(key); try { value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { return loadValue(key, valueLoader); } } finally { this.map.unlock(key); } } }
@SuppressWarnings("unchecked") public <T> T get(Object key, Callable<T> valueLoader) { Object value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { this.map.lock(key); try { value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { return loadValue(key, valueLoader); } } finally { this.map.unlock(key); } } }
public ValueWrapper putIfAbsent(Object key, Object value) { Object result = map.putIfAbsent(key, toStoreValue(value)); return result != null ? new SimpleValueWrapper(fromStoreValue(result)) : null; }
@SuppressWarnings("unchecked") public <T> T get(Object key, Callable<T> valueLoader) { Object value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { this.map.lock(key); try { value = lookup(key); if (value != null) { return (T) fromStoreValue(value); } else { return loadValue(key, valueLoader); } } finally { this.map.unlock(key); } } }