Java Code Examples for org.cache2k.CacheEntry#getValue()

The following examples show how to use org.cache2k.CacheEntry#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpiryTest.java    From cache2k with Apache License 2.0 5 votes vote down vote up
private static void entryHasException(final CacheEntry<Integer, Integer> e) {
  try {
    e.getValue();
    fail("exception expected");
  } catch (CacheLoaderException ex) {
  }
  assertNotNull(e.getException());
}
 
Example 2
Source File: BasicCacheOperationsWithoutCustomizationsTest.java    From cache2k with Apache License 2.0 5 votes vote down vote up
private static void entryHasException(final CacheEntry<Integer, Integer> e) {
  try {
    e.getValue();
    fail("exception expected");
  } catch (CacheLoaderException ex) {
  }
  assertNotNull(e.getException());
}
 
Example 3
Source File: SpringCache2kCache.java    From cache2k with Apache License 2.0 4 votes vote down vote up
private ValueWrapper returnWrappedValue(CacheEntry<Object, Object> entry) {
  final Object v = entry.getValue();
  return () -> v;
}
 
Example 4
Source File: ConcurrentMapWrapper.java    From cache2k with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Entry<K, V>> entrySet() {
  return new AbstractSet<Entry<K, V>>() {
    @Override
    public Iterator<Entry<K, V>> iterator() {
      final Iterator<CacheEntry<K,V>> it = cache.entries().iterator();
      return new Iterator<Entry<K, V>>() {

        @Override
        public boolean hasNext() {
          return it.hasNext();
        }

        @Override
        public Entry<K, V> next() {
          final CacheEntry<K, V> e = it.next();

          return new Entry<K, V>() {
            @Override
            public K getKey() {
              return e.getKey();
            }

            @Override
            public V getValue() {
              return e.getValue();
            }

            @Override
            public V setValue(V value) {
              throw new UnsupportedOperationException();
            }
          };
        }

        @Override
        public void remove() {
          it.remove();
        }
      };
    }

    @Override
    public int size() {
      return ConcurrentMapWrapper.this.size();
    }
  };
}