我有一组定义 API 的具体类,我想从 API 的实际实现中提取这些类的接口(interface)(即:本质上是类型层次结构和公共(public)方法)。
例如,如果 API 中的公共(public)类之一是
public class Foo extends Bar {
/* some fields which I don't care about */
public void method() {
/* implementation here */
}
public void otherMethod() {
/* implementation goes here */
}
/* some non public methods which I don't care about */
}
我想分成一个接口(interface)和一个实现
即
public interface FooInterface extends BarInterface {
public void method();
public void otherMethod()
}
public class Foo implements FooInterface {
/* etc etc */
}
和
有没有我可以使用的工具以自动方式进行这种分离,或者我是否必须推出自己的程序来完成这项工作?它需要是一种需要最少交互的工具。
最佳答案
我找到了解决方案!
Eclipse,支持重构脚本,脚本在 xml 中,但不是很人性化,但无论如何我已经生成了脚本,使 eclipse 执行所有重构。
有关eclipse 脚本重构的详细信息,look here并使用 eclipse 为您生成一些示例,以便您知道脚本应该是什么样子
关于java - 从 Java 类中提取接口(interface)的自动化方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4622633/