Groovy Deprecated Methods and Eclipse - Sorting

I have the following code that I wrote in groovy 1.8

someListOfLists.flatten().sort().unique() 

I switched to groovy 2.3.x and eclipse (using the e4.4 GroovyEclipse plugin for Juno from the snapshot release) shows that the sort () method is now deprecated for sort(Collection<T> self) , which we recommend using sort(Iterable<T> self) .

How do I now combine methods like this to avoid failure warnings?

I thought that since flatten () returns an ArrayList ( which is Iterable ), this should be fine. In addition, I see what to do.

 ((Iterable) someListOfLists.flatten()).sort().unique() 

removes the warning but looks ugly.

So, is this just an eclipse, not seeing that the correct type will actually be used, or is there some other way to express my chain of methods?

+5
source share
1 answer

Deprecation warnings are related to the fact that Eclipse maps Groovy methods to most of the obsolete DefaultGroovyMethods class, which was simply replaced by many separate other classes such as StringGroovyMethods, ResourceGroovyMethods, etc.

It seems that in version 2.7.1 of the Groovy plugin this has been fixed ... check your version of the plugin, maybe you just need to upgrade.

If this does not solve the problem, unfortunately, if you cannot force the Groovy plugin to change the method mapping, you will not be able to get rid of the warnings, as far as I know. In IntelliJ, I have the same problem.

+5
source

Source: https://habr.com/ru/post/1203608/


All Articles