I have classes
abstract class A {
//....
}
class B extends A {
//....
}
class C extends A {
//....
}
Then I have
interface Maker<T extends A> {
SomeClass make(T obj);
}
implementations for Maker class
class MakerForB implements Maker<B> { /*... */ }
class MakerForC implements Maker<C> { /*... */ }
and class Factory with one static method
class Factory {
public static SomeClass makeSomeClass(A obj) {
Maker maker = null;
if(obj instanceof B) maker = new MakerForB();
/* ... */
return maker.make(obj);
}
}
In that case I get warning that Maker is a raw type, when I declare Maker that way
Maker<?> maker = null;
I get exception (make is not applicable for the arguments A) on
return maker.make(obj);
What is the best way to get rid of these warnings without using
@SuppressWarnings("unchecked")