I have created two beans
class BackPageBean{
String backPage = null;
:
:
:
}
class InformationMessageBean{
String informationMessage = null;
:
:
:
}
Now, if a class is backpage aware then it will extend backPageBean, or if it need to show some kind of message then it extends InformationMessageBean.
class BackPageAware extends backPageBean{
}
class InfoMessAware extends InformationMessageBean{
}
someFunction () {
if ( theObject instanceOf backPageBean ) {
prepareTheBackPage ( theObject.getBackPage() );
}
if ( theObject instanceOf InformationMessageBean ) {
showtheInformation ( theObject.getMessage() );
}
}
Now the problem is, if i want to have a bean which is both BackPageAware as well as InformationAware then, as we don't have multiple inheritance, what should be the approach?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…