This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch groovyism/grails-databinding-core in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 3e44a5e97468ce58b455ddf39bccabd01e0ff9d3 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Fri Oct 16 15:39:13 2026 -0500 refactor(databinding-core): idiomatic-Groovy pass on the converted sources Applies the groovyisms cleanup to the 23 files converted from Java in grails-databinding-core. Most of the set (annotations, interfaces, DataBindingListenerAdapter, FrameworkPropertyNames, the four Spock specs) was already idiomatic Groovy out of the conversion; only two classes had real Java-shaped leftovers: - SimpleBindingError: private final fields + trivial getX() getters collapsed into Groovy final properties (same generated getter signatures, verified with javap -p). No subclasses, no reflective callers of the explicit getter methods. - BindingFormatASTTransformation: getMembers()/getName()/ getDeclaringClass().getName()/getLineNumber()/getColumnNumber()/ getErrorCollector() calls on AST nodes converted to property syntax (precedented elsewhere in this repo's AST transforms, e.g. grails-cache's annotationNode.members, field.declaringClass.name in ReflectionUtils); members.containsKey('code'/'value') converted to the 'x in map' idiom; the field/class-name string concatenation moved to a GString since it lands in a String-typed local. Left the deliberately literal, non-interpolated '$node.class / $parent.class' RuntimeException message untouched - it matches the original Java source's literal text and isn't an idiom issue. Kept the explicit (T) casts on astNodes[0]/astNodes[1] and the instanceof checks as-is per the AST-transform caution: no comparison/equality idiom touched. No behaviour or public API change. No test changes needed; the existing specs already assert through property syntax and already cover every path touched. Verification (grails-databinding-core): compileGroovy + compileTestGroovy clean; test 108/0 (1 skipped, pre-existing); codenarcMain 0 violations (codenarcTest/checkstyleMain are no-source/skipped for this module, unrelated to this change); javap dynamic-dispatch audit on both changed classes clean (only the harmless ScriptBytecodeAdapter.isIn/initMetaClass bytecode; every converted getter/property resolved to a direct invokevirtual). Co-Authored-By: Claude Sonnet 5 <[email protected]> --- .../compiler/BindingFormatASTTransformation.groovy | 16 +++++++-------- .../databinding/errors/SimpleBindingError.groovy | 24 ++++------------------ 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/grails-databinding-core/src/main/groovy/org/grails/databinding/compiler/BindingFormatASTTransformation.groovy b/grails-databinding-core/src/main/groovy/org/grails/databinding/compiler/BindingFormatASTTransformation.groovy index f817cbd58a..bc2502425f 100644 --- a/grails-databinding-core/src/main/groovy/org/grails/databinding/compiler/BindingFormatASTTransformation.groovy +++ b/grails-databinding-core/src/main/groovy/org/grails/databinding/compiler/BindingFormatASTTransformation.groovy @@ -46,22 +46,20 @@ class BindingFormatASTTransformation implements ASTTransformation, TransformWith final AnnotationNode annotationNode = (AnnotationNode) astNodes[0] final FieldNode fieldNode = (FieldNode) astNodes[1] - final Map<String, Expression> members = annotationNode.getMembers() - if (members == null || (!members.containsKey('code') && !members.containsKey('value'))) { - final String message = 'The @BindingFormat annotation on the field [' + - fieldNode.getName() + - '] in class [' + - fieldNode.getDeclaringClass().getName() + - '] must provide a value for either the value() or code() attribute.' + final Map<String, Expression> members = annotationNode.members + if (members == null || (!('code' in members) && !('value' in members))) { + final String message = "The @BindingFormat annotation on the field [${fieldNode.name}] " + + "in class [${fieldNode.declaringClass.name}] must provide a value for either the " + + 'value() or code() attribute.' error(source, fieldNode, message) } } protected void error(final SourceUnit sourceUnit, final ASTNode astNode, final String message) { - final SyntaxException syntaxException = new SyntaxException(message, astNode.getLineNumber(), astNode.getColumnNumber()) + final SyntaxException syntaxException = new SyntaxException(message, astNode.lineNumber, astNode.columnNumber) final SyntaxErrorMessage syntaxErrorMessage = new SyntaxErrorMessage(syntaxException, sourceUnit) - sourceUnit.getErrorCollector().addError(syntaxErrorMessage, false) + sourceUnit.errorCollector.addError(syntaxErrorMessage, false) } @Override diff --git a/grails-databinding-core/src/main/groovy/org/grails/databinding/errors/SimpleBindingError.groovy b/grails-databinding-core/src/main/groovy/org/grails/databinding/errors/SimpleBindingError.groovy index 8cb7ea6219..fc94d8e96a 100755 --- a/grails-databinding-core/src/main/groovy/org/grails/databinding/errors/SimpleBindingError.groovy +++ b/grails-databinding-core/src/main/groovy/org/grails/databinding/errors/SimpleBindingError.groovy @@ -29,10 +29,10 @@ import grails.databinding.errors.BindingError @CompileStatic class SimpleBindingError implements BindingError { - private final Object object - private final String propertyName - private final Object rejectedValue - private final Throwable cause + final Object object + final String propertyName + final Object rejectedValue + final Throwable cause SimpleBindingError(Object object, String propertyName, Object rejectedValue, Throwable cause) { @@ -42,20 +42,4 @@ class SimpleBindingError implements BindingError { this.cause = cause } - Object getObject() { - return object - } - - String getPropertyName() { - return propertyName - } - - Object getRejectedValue() { - return rejectedValue - } - - Throwable getCause() { - return cause - } - }
