Reputation: 524
I have a class like this:
public class TestObject
{
List<String> data;
public List<String> getData()
{
return data;
}
public void setData(List<String> inputData)
{
data = inputData;
}
}
I checked the option in Preferences -> Java -> Editor -> Save Actions -> Configure -> Unnecessary Code -> Remove redundant type arguments (1.7 or higher)
Now I create a Main class:
public class Main
{
public static void main(String[] args)
{
TestObject o = new TestObject();
o.setData(new ArrayList<String>());
}
}
Now I save the file.
I would have expected eclipse to remove the "String" type argument inside the setter on saving the file, but it stayed there.
Any ideas why this is the case (is there a reason for it or did I miss a setting I have to enable?)
Upvotes: 0
Views: 815
Reputation: 15906
It only remove for code like below:
List<String> yourList = new ArrayList<String>()
to
List<String> yourList = new ArrayList<>()
If this is passed in method like your code, eclipse will not remove that.
Not sure exactly but as from the below bug looks like its only remove when type arguments is redundant.
Reduce type arguments to diamond <> (1.7 or higher)
o Never o Only if redundant
Upvotes: 1