V
VisionSet
In an inheritence structure of classes the superclass has:
Object record
public void setRecord(int i) {
record = model.getRecord(i)
}
this method is not overridden.
The subclasses have a package private getFlavouredRecord() method that
returns 'record' cast to its 'flavoured' type.
Should I override setRecord to ensure type is correct:
public void setRecord(int i) {
super.setRecord(i);
if(record != null && ! record instanceof Raspberry) {
throw new ClassCastException();
}
}
A bit bloaty for every subclass, but sensible?
Since setRecord() is public then perhaps I should, otherwise a bit OTT?
Object record
public void setRecord(int i) {
record = model.getRecord(i)
}
this method is not overridden.
The subclasses have a package private getFlavouredRecord() method that
returns 'record' cast to its 'flavoured' type.
Should I override setRecord to ensure type is correct:
public void setRecord(int i) {
super.setRecord(i);
if(record != null && ! record instanceof Raspberry) {
throw new ClassCastException();
}
}
A bit bloaty for every subclass, but sensible?
Since setRecord() is public then perhaps I should, otherwise a bit OTT?