I just found it very annoying when I am constructing a new method that I
have to create a list of parameters and then pass it the constructor
Here is an example:
I want to create a setter method so I go like this:
Parameter p = new Parameter(field.getType(), new VariableDeclaratorId("id"));
List<Parameter> ps = new ArrayList<Parameter>();
ps.add(p);
MethodDeclaration setter = new MethodDeclaration(ModifierSet.PUBLIC,
field.getType(), "setId", ps);
Instead I want to be able to do all that one line:
MethodDeclaration setter = new MethodDeclaration(ModifierSet.PUBLIC,
field.getType(), "setId", new
Parameter(field.getType(), new VariableDeclaratorId("id"));
it simplify things a lot ..
So the signature of the constructor I am suggesting is this:
public MethodDeclaration(int modifiers, Type type, String name,
Parameter... parameters);
and the complete implementation would be something like this in the
MethodDeclaration class
public MethodDeclaration(int modifiers, Type type, String name,
Parameter... parameters) {
this.modifiers = modifiers;
this.type = type;
this.name = name;
this.parameters = Arrays.asList(parameters);
}
Thanks
Original issue reported on code.google.com by same%nan...@gtempaccount.com on 10 Oct 2009 at 8:27
Original issue reported on code.google.com by
same%nan...@gtempaccount.com
on 10 Oct 2009 at 8:27