Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.0-beta-8
-
None
-
All
Description
In a builder, if the number or type of arguments is wrong, they are silently ignored. Instead, it would be better to either log an error message or (preferably) throw an exception.
In groovy/util/BuilderSupport.java, line 88, is doInvokeMethod(). The changes should go in there: have a default for the switch statement, plus in case 2:, the last "if" should have an else for the error.
Alternately, groovy could support foo(object, key:value) in addition to foo(key:value, object), which it already supports. At least in SwingBuilder, that's more natural to me. e.g. now I can declare a label:
label("Blah")
If I want to add a constraint it would be natural to write:
label("Blah", constriants:SOUTH)
Now I have to add a text: in front of the text:
label(text:"Blah", constraints:SOUTH)