I have a generic interface defined as:
public interface Service<T extends Slicer, E extends Slice> {
}
And an implementation:
public class DynamoDbService implements Service<DynamoDbSlicer, DynamoDbSlice> {
}
If I try to instantiate DynamoDbService
and assign it to a variable of type Service<DynamoDbSlicer, DynamoDbSlice>
like so:
public class Test {
private void test() {
final Service<Slicer, Slice> service = new DynamoDbService();
}
}
I get an incompatible types
error:
Incompatible types.
Required: Service <Slicer, Slice>
Found: DynamoDbService
As DynamoDbService
implements the generic interface, shouldn't this be ok? The following example without generics works how I'd expect and how I'd like the previous example to work:
public interface ThingInterface {
}
public class Thing implements ThingInterface {
}
private void thingTest() {
final ThingInterface thingInteface = new Thing();
}