本文介绍了列出所有具有完全限定名称的子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个给定类的所有子类的列表,其全部限定名称。我想将它从Eclipse中复制并粘贴到这样的文本文件中:

I would like to get a list of all subclasses of a given class with their fully qualified names. I wanted to copy it from Eclipse and paste into a text file like this:

 some.package.Class1
 some.package.Class2
 some.other.package.Class3
 ...

我试过:


  • 搜索| Java |类型,对实现者的限制但是由于一些奇怪的原因,这个没有列出子类的子类,只是直接后代。

  • 开始层次结构查看打印树组件中所有子类的类,此视图不允许我选择所有行并复制其名称。

  • doing Search | Java | Type, Limit to implementors. But this one for some strange reasons doesn't list subclasses of subclasses, only direct descendants.
  • opening Hierarchy view for the class which prints all the subclasses in a tree component, but this view doesn't allow me to select all the rows and copy their names.

其他任何技巧?有数百个类,所以我想避免手动执行。

Any other tricks? There are hundreds of classes, so I wanted to avoid doing it manually.

推荐答案

按照可以以编程方式执行。这是一个耻辱的Eclipse不能做它的OOTB。在Java代码中执行此操作可以无需额外的费用进行过滤(例如!(klazz.isEnum()))。

Following the pattern described in http://internna.blogspot.com/2007/11/java-5-retrieving-all-classes-from.html one can do it programmatically. It's a shame Eclipse can't do it OOTB. Doing it in Java code allows to do the filtering with no additional cost (e.g. !(klazz.isEnum())).

这篇关于列出所有具有完全限定名称的子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 18:56