I refactored a class out in to many that implement an interface instead. It works fine, however I'd like to be able to use the code without having to infer or suppress warnings everywhere.
//Item is a raw type. References to generic type Item<T> should be parameterized.
public interface Item<T extends Item>
{
// Item is a raw type. References to generic type Item<T> should be parameterized.
public static final Item DEFAULT_ITEM = new FooItem(Color.RED);
// Because using "something = new Item(Default_Item)" won't work.
public T Copy();
public void Foo();
public void Bar();
}
public class RepairMan
{
// Item is a raw type. References to generic type Item<T> should be parameterized.
Item itemNeedingRepairs;
// Item is a raw type. References to generic type Item<T> should be parameterized.
public RepairMan(final Item item)
{
itemNeedingRepairs = item.Copy();
}
}
I would like to be able to use Item as a regular non-interface version in the majority of code. There's too many places to add ignore warnings, and Item everywhere doesn't seem appealing either.
Some notes:
- Item doesn't make sense being a class in my application.
- I can get away with a non-generic interface in this instance, though it preferrable with it, but I'd like to explore the problem for the sake of learning.
Feel free to adjust the title if there's a better way to describe this problem, I'm unsure.