java - Implement interface other than from class signature -
let's say, example, wanted group classes in jar library fit definition of custom interface. since can't edit classes inside jar in order implement interface, there other way use these classes though implemented interface?
example: have uneditable classes a
, b
. have static method in different class accepts objects belonging interface i
. how can pass in a
, b
objects without making method accept object
objects. want give a
, b
new functionality only can have.
from edit , based on comment: create class implement interface , serve wrapper classes , b. facade design pattern. here's pretty basic simple example in code:
public interface { void methodfromexternalaclass(); void methodfromexternalbclass(); } public class myclass implements { @override public void methodfromexternalaclass() { new a().somemethod(); } @override public void methodfromexternalbclass() { new b().somemethod(); } }
Comments
Post a Comment