@Override public Class<K> getKeyType() { if (delegate.getKeyType() == null) { return (Class<K>) Object.class; } return delegate.getKeyType(); }
@Override public Class<K> getKeyType() { if (delegate.getKeyType() == null) { return (Class<K>) Object.class; } return delegate.getKeyType(); }
@Override public Class<K> getKeyType() { return delegate.getKeyType(); }
@Override public Class<K> getKeyType() { if (delegate.getKeyType() == null) { return (Class<K>) Object.class; } return delegate.getKeyType(); }
@Override public Class<K> getKeyType() { return delegate.getKeyType(); }
public synchronized <K, V> Cache<K, V> maybeCreateCache(final String name, final MutableConfiguration<K, V> mutableConfiguration) { checkNotNull(name); checkNotNull(mutableConfiguration); Cache<K, V> cache = manager() .getCache(name, mutableConfiguration.getKeyType(), mutableConfiguration.getValueType()); if (cache == null) { cache = manager().createCache(name, mutableConfiguration); log.debug("Created cache: {}", cache); } else { log.debug("Re-using existing cache: {}", cache); } return cache; }
/** * Tests use of default constructor and generics, this time setting the desired type * * @throws IllegalAccessException * @throws InstantiationException */ @Test public void testDefaultConstructorWithSetTypes() throws IllegalAccessException, InstantiationException { MutableConfiguration<String, String> configuration = new MutableConfiguration<String, String>().setTypes(String.class, String.class); Class<String> keyType = configuration.getKeyType(); String s = keyType.newInstance(); //no exception. This sets the types. }
/** * Tests use of default constructor and generics, this time setting the desired type using the constructor * * @throws IllegalAccessException * @throws InstantiationException */ @Test public void testDefaultConstructorWithTypeConstructor() throws IllegalAccessException, InstantiationException { MutableConfiguration<String, String> configuration = new MutableConfiguration<String, String>().setTypes(String.class, String.class); Class<String> keyType = configuration.getKeyType(); String s = keyType.newInstance(); //no exception. This sets the types. }
/** * Tests use of default constructor and generics. * * @throws IllegalAccessException * @throws InstantiationException */ @Test public void testDefaultConstructor() throws IllegalAccessException, InstantiationException { try { MutableConfiguration<String, String> configuration = new MutableConfiguration<String, String>(); assertEquals(Object.class, configuration.getKeyType()); assertEquals(Object.class, configuration.getValueType()); Class<String> keyType = configuration.getKeyType(); String s = keyType.newInstance(); } catch (ClassCastException e) { //expected } }