从 Java 类中提取接口的自动化方法 [英] Automated way to Extract Interfaces from a Java Class

查看:20
本文介绍了从 Java 类中提取接口的自动化方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组定义 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆