Here's the scenario.
Our app has a very trivial interface for cache implementations, with methods similar to a Map:
public interface ICache<K, V> {
To add a concrete cache implementation we implement the interface and wrap a cache framework like EHCache, Redis, memcached etc. Example (the fact that its EHCache here is immaterial to the question):
public abstract class EHCacheWrapper<K,V> implements ICache<K, V> {
Next we have an implementation of EHCacheWrapper called AuthenticationCache:
public class AuthenticationCache
extends EHCacheWrapper<AuthenticationCacheKey, AuthenticationCacheEntry> {
So far so good.
The AuthenticationCache object has some additional methods beyond EHCacheWrapper or ICache. What we want to add are interfaces for AuthenticationCache, AuthenticationCacheKey, and AuthenticationCacheEntry:
public interface IAuthenticationCacheKey extends Serializable {
public interface IAuthenticationCacheEntry extends Serializable {
public interface IAuthenticationCache extends ICache<IAuthenticationCacheKey,IAuthenticationCacheEntry>{
So now we have:
public class AuthenticationCache
extends EHCacheWrapper<AuthenticationCacheKey, AuthenticationCacheEntry>
implements IAuthenticationCache {
Which gives the compiler error:
The interface ICache cannot be implemented more than once with different arguments: ICache<AuthenticationCacheKey,AuthenticationCacheEntry> and ICache<IAuthenticationCacheKey,IAuthenticationCacheEntry>
How do I achieve what we're after here?