Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search for all methods in a project that return implementation of Collection interface?

I've been reading Josh Bloch's 'Effective Java 2nd Edition'. Item 43 states 'Return empty arrays or collections, not nulls'. My question is how can I search for all methods in a project that return an implementation of java.util.Collection interface? IDE that is used is Eclipse, but any way of finding the right result is acceptable, e.g. regex or some other IDE.

like image 898
Boris Pavlović Avatar asked Feb 25 '09 09:02

Boris Pavlović


1 Answers

Found this in Eclipse Help:

To search for methods with a specific return type, use "* " as follows:

  1. Open the search dialog and click on the Java Search tab.
  2. Type '*' and the return type, separated by a space, in the Search string.
  3. Select the Case sensitive checkbox.
  4. Select Method and Declarations and then click Search.

It can help finding all methods that return specific types but not implementations of some interface.

like image 131
Boris Pavlović Avatar answered Oct 07 '22 19:10

Boris Pavlović