Deriving generic type from generic ArrayList
I have two types that extend the generic ArrayList type.
public class BuyersGuideResponse extends ArrayList {
private void checkStatusAttributes(){ ... }
private void addItems(){ ... }
}
public class CatalogEngineTypeResponse extends ArrayList {
private void checkStatusAttributes(){ ... }
private void addItems(){ ... }
}
The checkStatusAttributes method is identical in both types so I'd like to
create a abstract generic intermediate type. I currently have
public class ArrayListResponse extends ArrayList {
// no implementation
}
public class BuyersGuideResponse extends ArrayListResponse
{
// implementation unchanged
...
private void addItems()
{
NodeList nodes =
doc.getElementsByTagName(CatalogConst.BUYERS_GUIDE_ITEM_NODE_NAME);
for(int i = 0; i < nodes.getLength(); i++)
{
add(new BuyersGuideItem(nodes.item(i)));
}
...
}
...
}
When compiling the following error is generated :
quote - BuyersGuideResponse.java:51: error: unexpected type
add(new BuyersGuideItem(nodes.item(i)));
^
required: class
found: type parameter BuyersGuideItem
where BuyersGuideItem is a type-variable
BuyersGuideItem extends Object declared in BuyersGuideItem.java
end quote -
Where am I going wrong?
No comments:
Post a Comment