从 Java 类中提取接口的自动化方法 [英] Automated way to Extract Interfaces from a Java Class
问题描述
我有一组定义 API 的具体类,我想从 API 的实际实现中提取这些类的接口(即:本质上是类型层次结构和公共方法).
I've got a collection of concrete Classes which define an API, and I would like to extract the Interface of these classes (ie: essentially the type hierarchy and public methods) from the actual implementation of the API.
例如,如果 API 中的公共类之一是
So for example if one of the public classes in the API is
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 */
}
我想分解一个接口和一个实现
I would like to break into an interface and an implementation
即
public interface FooInterface extends BarInterface {
public void method();
public void otherMethod()
}
public class Foo implements FooInterface {
/* etc etc */
}
和
有没有我可以使用的工具以自动方式进行这种分离,还是我将不得不推出自己的程序来完成这项工作?它需要是一个需要最少交互的工具.
Is there a tool I can use to do this separation in automated way, or am I going to have to roll my own program to do the job? It needs to be a tool that requires minimal interaction.
推荐答案
我找到了解决方案!
Eclipse,支持重构脚本,脚本是 xml 格式,但对人类不太友好,但我已经生成了脚本,使 eclipse 执行所有重构.
Eclipse, has support for refactoring scripts, the scripts are in xml yet not very human friendly but I have generated the scripts anyway that makes eclipse perform all the refactoring.
关于eclipse脚本重构的细节,看这里 并使用 eclipse 为您生成一些示例,以便您知道脚本应该是什么样子
For details of eclipse script refactoring, look here and use eclipse to generate a few examples for you so you know what the script should look like
这篇关于从 Java 类中提取接口的自动化方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!