How can I make this java generic cast ?
public interface IField {
}
class Field implements IField { // package private class
}
public class Form {
private List<Field> fields;
public List<IField> getFields() {
return this.fields;
}
}
The return statement throws a compiler error (I know the reason - I read the generics tutorial) but it would be very handy to write such code.
If I declared "fields" as List I would need to use a lot of casts to Field in other methods of a Form class .
Can I force that damn compiler to bend it's rules and compile that return statement ?
Thanks in advance.