inheritance - Override interface instead of parent class in Java -
i have class extends class (reloadableresourcebundlemessagesource
) , implements interface(mymessageprovider
) this:
public class custommessagesource extends reloadableresourcebundlemessagesource implements mymessageprovider{ @override public string getmessage(string code, object[] objects, final locale locale{ try { return getmessage(code, objects, locale); } catch (nosuchmessageexception e) { return code; } } }
both interface , parent class have getmessage
function want override interface one. code gives compile error because getmessage in parent class (reloadableresourcebundlemessagesource
) final
.
if override getmessageinternal()
method not final
, , called by getmessage()
methods, can affect outcome not returning null. not need change calls getmessage()
methods in code, call internal method themselves.
@override public string getmessageinternal(string code, object[] objects, final locale locale) { string foo = super.getmessageinternal(code, objects, locale); return foo == null ? code : foo; } }
Comments
Post a Comment