I’m using an (open-source) API in my Java project and referencing interfaces from it. One interface (Foo) is used extensively both in the API and in projects that use it. For my project, I’d like to use an interface which only exposes a subset of the methods that Foo does, such that Foo would inherit methods from my new interface (Bar). I don’t want to change the interface of Foo at all; rather, I’d like to be able to write classes which implement Bar, and then manipulate those along with classes which implement Foo as if they are all Bar.
Since the API is in a different package, is there any way to accomplish this such that Bar is a superclass (interface) of all Foo?
You’re probably going to need to use an Aspect to make this happen. It looks like AspectJ has a @DeclareParents that might do what you want.