简体   繁体   中英

Eclipse tool to compare two interfaces

I have to choose between two complicated interfaces for a method parameter: InterfaceParent and InterfaceChild .

The interface InterfaceChild extends the interface InterfaceParent and one of them will become part of methodX 's signature, depending on which interface I find more fitting.

By definition, InterfaceParent and InterfaceChild share many methods so comparing them is difficult by looking just at the source files. This is problem I am having.

How do I quickly compare and view differences between two interfaces using Eclipse?


Read more for an explanatory scenario or stop reading now if the description above was sufficient:

Think of interface java.util.Collection<E> as InterfaceParent and interface java.util.List<E> as InterfaceChild . Imagine I had to choose between them.

This case is similar to mine because List<E> extends Collection<E> and thus the interfaces share many methods.

Try looking at the source files for these two interfaces: both files have "stubs" for all methods so comparing them at a glance is very difficult by laying out two code editors next to one other.

Collection<E> and List<E> are small interfaces by comparison so my problem is even bigger than this but let's stay with Collection<E> and List<E> in our example for simplicity's sake.

I wish I could use my IDE (Eclipse) to show me the differences of these interfaces, or a command line tool to output the method signatures of both.

With a comman line tool, I could dump the output to text files, sort the files and run a diff tool to see the differences, hiding the common methods.

In the example, I could quickly find out which methods are defined on List<E> which are not defined on Collection<E> , and choose one interface or the other for methodX based on this difference.

I am not aware of any tools which perform this sort of "reflection" on Java objects so that one may pass to them a fully qualified class name and get a public interface definition output stream. Please let me know if there are any.

Clearly doing this using a command line tool would become tedious after a while so I am wondering: is there something similar in Eclipse? The Outline feature is perfect for an at-a-glance overview of a type, but could I compare two Outlines? The "code folding" feature is great to reduce a source file to just "names of methods" but there is nothing that hides common methods between two interfaces and shows the differences?

How would you go about doing this sort of thing without leaving Eclipse?

Select two interfaces and right click on them Choose Compare with --> each other

比较每个

image source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM