How can I access the Groovy setter shortcut for multiparameter setters?
-
20-08-2019 - |
Question
Let's say I have a java.util.Properties object. The Properties object has a method called setProperty(String name,String value). Is there a setter shortcut for it?
EDIT: maybe the Properties class was not the best example, because I think it handles that by adding the keys as properties. But how about a setter method that takes an arbitrary number of parameters?
Solution
The short answer is 'no'. Groovy only provides shortcuts for getters/setters properties which follow the JavaBeans convention
T getX()
void setX(T value)
where X is the name of the property and T is the type of the property. Methods that are named "set*" and have more than one argument do not qualify.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow