Java – can eclipse automatically generate interfaces for third-party library classes?

I work with Apache's ftpclient class in the Apache public network library Unfortunately, it does not implement interfaces for most functions, which makes it difficult to use its test classes So, I thought I would create my own class to wrap this and implement an interface Anyway, this is the background My question is, is it possible to generate an interface in eclipse (similar to refactor - > extract interface), but what about the third-party code in the jar file?

Just to clarify, I am not looking for an ftpclient to implement a new interface, but to create an interface that mimics the same public API as the ftpclient Then, I can create my own class, implement this interface and wrap ftpclient

Solution

Um Why not start an empty class like

class MyWrapper {

    private Referent client;
}

Then, I will do "source – > generate delegate methods", fill in the empty class, and delegate calls to the underlying original object as needed Starting with this class, you can now use "refactor – > extract interface"... With the wrapper you need to produce, this will solve both problems (wrapper generation interface generation)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>