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

查看:320
本文介绍了从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 */

 }

我想闯入界面和实现

ie

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天全站免登陆