Following the discussion in #11582, the Maven 4 API should consistently use noun-style accessors (record-accessor pattern) for immutable value types, in line with modern JDK conventions (see detailed analysis).
Several hand-crafted API interfaces already follow this pattern (XmlNode, PathType, Lifecycle.Phase, Packaging, ExtensibleEnum, OsService, CIInfo). The remaining core value type interfaces should be migrated as well.
Scope
For each interface, add the noun-style accessor as the primary abstract method and convert the existing getX() to a default method delegating to it, annotated with @Deprecated(since = "4.1.0", forRemoval = true). Boolean queries (is*()) and conversion methods (to*()) are left as-is.
Interfaces to migrate
| Interface |
Accessors to add |
Artifact |
groupId(), artifactId(), version(), baseVersion(), classifier(), extension() |
ArtifactCoordinates |
groupId(), artifactId(), classifier(), versionConstraint(), extension() |
Dependency |
type(), scope() |
DependencyCoordinates |
type(), scope(), optional() |
DownloadedArtifact |
path() |
Exclusion |
groupId(), artifactId() |
Project |
groupId(), artifactId(), version(), packaging(), model(), pomPath(), basedir(), rootDirectory() |
VersionConstraint |
versionRange(), recommendedVersion() |
VersionRange / VersionRange.Boundary |
upperBoundary(), lowerBoundary(), version() |
~42 methods across 9 interfaces.
Rationale
Every new immutable type introduced in the JDK since Java 8 — unconstrained by pre-existing hierarchies — uses noun-style accessors exclusively. The getX() prefix is the JavaBeans convention for mutable components with getters/setters. See #11582 for the full JDK 8–25 survey.
Related: #11582
Following the discussion in #11582, the Maven 4 API should consistently use noun-style accessors (record-accessor pattern) for immutable value types, in line with modern JDK conventions (see detailed analysis).
Several hand-crafted API interfaces already follow this pattern (
XmlNode,PathType,Lifecycle.Phase,Packaging,ExtensibleEnum,OsService,CIInfo). The remaining core value type interfaces should be migrated as well.Scope
For each interface, add the noun-style accessor as the primary abstract method and convert the existing
getX()to adefaultmethod delegating to it, annotated with@Deprecated(since = "4.1.0", forRemoval = true). Boolean queries (is*()) and conversion methods (to*()) are left as-is.Interfaces to migrate
ArtifactgroupId(),artifactId(),version(),baseVersion(),classifier(),extension()ArtifactCoordinatesgroupId(),artifactId(),classifier(),versionConstraint(),extension()Dependencytype(),scope()DependencyCoordinatestype(),scope(),optional()DownloadedArtifactpath()ExclusiongroupId(),artifactId()ProjectgroupId(),artifactId(),version(),packaging(),model(),pomPath(),basedir(),rootDirectory()VersionConstraintversionRange(),recommendedVersion()VersionRange/VersionRange.BoundaryupperBoundary(),lowerBoundary(),version()~42 methods across 9 interfaces.
Rationale
Every new immutable type introduced in the JDK since Java 8 — unconstrained by pre-existing hierarchies — uses noun-style accessors exclusively. The
getX()prefix is the JavaBeans convention for mutable components with getters/setters. See #11582 for the full JDK 8–25 survey.Related: #11582