J
Jason Cavett
So, here's a weird problem I ran into using generics (see my other
post - http://groups.google.com/group/comp.lang.java.programmer/browse_frm/thread/5939fff0ed09efd6#)
The issue revolves around general use of a Generics class. For
example, I have a List of Generic objects that I need to iterate
through. So...something like this...
// generics class
public abstract class ErrorRule <T extends DataObject> {
public abstract boolean verify(T object);
}
// suite to run the error rules; each DataObject has its own suite
public abstract class ErrorSuite {
public boolean verifyAllRules(DataObject object) {
// rules defined in the concrete class
// this throws the following warning, though...
// ErrorRule is a raw type. References to generic type
ErrorRule<T> should be parameterized
for(ErrorRule rule : this.rules) {
rule.verify(object);
}
}
}
So, if I paramaterize it with <? extends DataModel> then the
"rule.verify()" gets the following error...
The method verify(capture#2-of ? extends DataObject) in the type
ErrorRule<capture#2-of ? extends DataObject> is not applicable for the
arguments (DataObject)
Whoa...any help with that error? Any way to fix this (without doing
@SuppressWarnings)?
Thanks
post - http://groups.google.com/group/comp.lang.java.programmer/browse_frm/thread/5939fff0ed09efd6#)
The issue revolves around general use of a Generics class. For
example, I have a List of Generic objects that I need to iterate
through. So...something like this...
// generics class
public abstract class ErrorRule <T extends DataObject> {
public abstract boolean verify(T object);
}
// suite to run the error rules; each DataObject has its own suite
public abstract class ErrorSuite {
public boolean verifyAllRules(DataObject object) {
// rules defined in the concrete class
// this throws the following warning, though...
// ErrorRule is a raw type. References to generic type
ErrorRule<T> should be parameterized
for(ErrorRule rule : this.rules) {
rule.verify(object);
}
}
}
So, if I paramaterize it with <? extends DataModel> then the
"rule.verify()" gets the following error...
The method verify(capture#2-of ? extends DataObject) in the type
ErrorRule<capture#2-of ? extends DataObject> is not applicable for the
arguments (DataObject)
Whoa...any help with that error? Any way to fix this (without doing
@SuppressWarnings)?
Thanks