This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 18ee058b63 feat: add noun-style accessors to generated model classes 
(#14067)
18ee058b63 is described below

commit 18ee058b63c3706c5fd0a29c7657b166cb7eed76
Author: Guillaume Nodet <[email protected]>
AuthorDate: Mon Nov 23 10:21:11 2026 +0100

    feat: add noun-style accessors to generated model classes (#14067)
    
    Modify the shared Modello Velocity template (model.vm) so all generated
    model classes in api/maven-api-model, maven-api-settings,
    maven-api-toolchain, maven-api-metadata, maven-api-plugin, and
    maven-api-cli now emit both:
    
    1. A noun-style accessor (primary): fieldName()
    2. A deprecated JavaBeans getter (delegates to noun): getFieldName()
    
    For boolean fields, isFieldName() delegates to fieldName().
    
    The root-class methods getNamespaceUri() and getModelEncoding() are
    also deprecated in favor of namespaceUri() and modelEncoding().
    
    Infrastructure methods (getLocation, getLocationKeys, getLocations,
    getImportedFrom) are intentionally excluded from this pattern.
    
    This aligns the generated model classes with the noun-style accessor
    convention already established for Maven 4 API types like Repository,
    Session, and other @Immutable interfaces (since 4.1.0).
---
 src/mdo/model.vm | 46 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/mdo/model.vm b/src/mdo/model.vm
index b048860b77..6ae4a22b40 100644
--- a/src/mdo/model.vm
+++ b/src/mdo/model.vm
@@ -204,14 +204,42 @@ public class ${class.name}
 
     #end
     #if ( $class == $root )
-    public String getNamespaceUri() {
+    /**
+     * The namespace URI of the model.
+     *
+     * @return a {@code String}
+     * @since 4.0.0
+     */
+    public String namespaceUri() {
         return namespaceUri;
     }
 
-    public String getModelEncoding() {
+    /**
+     * @deprecated Use {@link #namespaceUri()} instead.
+     */
+    @Deprecated(since = "4.0.0", forRemoval = true)
+    public String getNamespaceUri() {
+        return namespaceUri();
+    }
+
+    /**
+     * The encoding used for the model.
+     *
+     * @return a {@code String}
+     * @since 4.0.0
+     */
+    public String modelEncoding() {
         return modelEncoding;
     }
 
+    /**
+     * @deprecated Use {@link #modelEncoding()} instead.
+     */
+    @Deprecated(since = "4.0.0", forRemoval = true)
+    public String getModelEncoding() {
+        return modelEncoding();
+    }
+
     #end
     #foreach ( $field in $class.getFields($version) )
       #set ( $cap = $Helper.capitalise( $field.name ) )
@@ -228,6 +256,7 @@ public class ${class.name}
       #end
      *
      * @return a {@code ${type}}
+     * @since 4.0.0
      */
       #foreach( $ann in ${field.annotations} )
     ${ann}
@@ -235,10 +264,21 @@ public class ${class.name}
       #if ( $field.type == "java.util.List" || $field.type == 
"java.util.Properties" )
     @Nonnull
       #end
-    public ${type} ${pfx}${cap}() {
+    public ${type} ${field.name}() {
         return this.${field.name};
     }
 
+    /**
+     * @deprecated Use {@link #${field.name}()} instead.
+     */
+    @Deprecated(since = "4.0.0", forRemoval = true)
+      #if ( $field.type == "java.util.List" || $field.type == 
"java.util.Properties" )
+    @Nonnull
+      #end
+    public ${type} ${pfx}${cap}() {
+        return ${field.name}();
+    }
+
     #end
     #if ( $locationTracking && !$class.superClass )
     /**

Reply via email to