gnodet opened a new issue, #13830:
URL: https://github.com/apache/maven/issues/13830
# Add noun-style accessors to remaining `@Immutable` API types (deprecating
old-style `getXxx()`)
## Background
Maven 4.1.0 started the migration of `@Immutable` API types to **noun-style
accessors** (e.g. `id()`, `type()` instead of `getId()`, `getType()`),
consistent with the immutable value-object pattern and established in JDK types
like `Record`. The reference implementation is
`org.apache.maven.api.Repository`, which now exposes `id()` and `type()` as the
canonical accessors while `getId()` / `getType()` are deprecated
(`@Deprecated(since = "4.1.0", forRemoval = true)`) with default
implementations delegating to the new names.
This issue tracks the remaining `@Immutable` interfaces that still only
expose the old `getXxx()` / `isXxx()` style and need the same treatment.
## Scope
The following interfaces need new noun-style accessors added, with the old
getters kept as `@Deprecated(since = "4.1.0", forRemoval = true)` default
methods delegating to the new ones.
### `maven-api-core` — `org.apache.maven.api`
**`Artifact`**
- `isSnapshot()` → add `boolean snapshot()`
**`Dependency`**
- `isOptional()` → add `boolean optional()`
**`Type`**
- `getLanguage()` → add `Language language()`
- `getExtension()` → add `String extension()`
- `getClassifier()` → add `String classifier()`
- `isIncludesDependencies()` → add `boolean includesDependencies()`
- `getPathTypes()` → add `Set<PathType> pathTypes()`
> Note: `Packaging.language()` already exists as a noun-style `default`
method but it internally calls `type().getLanguage()` — once `Type.language()`
is added, its body must be updated to call `type().language()`.
### `maven-api-core` — `org.apache.maven.api.services`
**`Request`**
- `getSession()` → add `S session()`
- `getTrace()` → add `RequestTrace trace()`
**`Result`**
- `getRequest()` → add `REQ request()`
**`BuilderProblem`**
- `getSource()` → add `String source()`
- `getLineNumber()` → add `int lineNumber()`
- `getColumnNumber()` → add `int columnNumber()`
- `getLocation()` → add `String location()`
- `getException()` → add `Exception exception()`
- `getMessage()` → add `String message()`
- `getSeverity()` → add `Severity severity()`
**`RepositoryAwareRequest`** (extends `Request`)
- `getRepositories()` → add `List<RemoteRepository> repositories()`
**`ArtifactCoordinatesFactoryRequest`**
- `getGroupId()` → add `String groupId()`
- `getArtifactId()` → add `String artifactId()`
- `getVersion()` → add `String version()`
- `getClassifier()` → add `String classifier()`
- `getExtension()` → add `String extension()`
- `getType()` → add `String type()`
- `getCoordinatesString()` → add `String coordinatesString()`
**`ArtifactDeployerRequest`**
- `getRepository()` → add `RemoteRepository repository()`
- `getArtifacts()` → add `Collection<ProducedArtifact> artifacts()`
- `getRetryFailedDeploymentCount()` → add `int retryFailedDeploymentCount()`
**`ArtifactFactoryRequest`**
- `getGroupId()` → add `String groupId()`
- `getArtifactId()` → add `String artifactId()`
- `getVersion()` → add `String version()`
- `getClassifier()` → add `String classifier()`
- `getExtension()` → add `String extension()`
- `getType()` → add `String type()`
**`ArtifactInstallerRequest`**
- `getArtifacts()` → add `Collection<ProducedArtifact> artifacts()`
**`ArtifactResolverRequest`**
- `getCoordinates()` → add `Collection<ArtifactCoordinates> coordinates()`
**`DependencyCoordinatesFactoryRequest`**
- `getScope()` → add `DependencyScope scope()`
- `isOptional()` → add `boolean optional()`
- `getExclusions()` → add `Collection<Exclusion> exclusions()`
**`DependencyResolverRequest`**
- `getRequestType()` → add `RequestType requestType()`
- `getProject()` → add `Optional<Project> project()`
- `getRootArtifact()` → add `Optional<Artifact> rootArtifact()`
- `getRoot()` → add `Optional<DependencyCoordinates> root()`
- `getDependencies()` → add `Collection<DependencyCoordinates>
dependencies()`
- `getManagedDependencies()` → add `Collection<DependencyCoordinates>
managedDependencies()`
- `getVerbose()` → add `boolean verbose()`
- `getPathScope()` → add `PathScope pathScope()`
- `getPathTypeFilter()` → add `Predicate<PathType> pathTypeFilter()`
- `getTargetVersion()` → add `Version targetVersion()`
**`ModelBuilderRequest`**
- `getSource()` → add `Source source()`
- `getRequestType()` → add `RequestType requestType()`
- `isLocationTracking()` → add `boolean locationTracking()`
- `isRecursive()` → add `boolean recursive()`
- `getProfiles()` → add `List<Profile> profiles()`
- `getActiveProfileIds()` → add `List<String> activeProfileIds()`
- `getInactiveProfileIds()` → add `List<String> inactiveProfileIds()`
- `getSystemProperties()` → add `Map<String, String> systemProperties()`
- `getUserProperties()` → add `Map<String, String> userProperties()`
- `getRepositoryMerging()` → add `RepositoryMerging repositoryMerging()`
- `getLifecycleBindingsInjector()` → add `LifecycleBindingsInjector
lifecycleBindingsInjector()`
**`ProjectBuilderRequest`**
- `getPath()` → add `Optional<Path> path()`
- `getSource()` → add `Optional<Source> source()`
- `isAllowStubModel()` → add `boolean allowStubModel()`
- `isRecursive()` → add `boolean recursive()`
- `isProcessPlugins()` → add `boolean processPlugins()`
- `getRepositories()` → add `List<RemoteRepository> repositories()`
**`SettingsBuilderRequest`**
- `getInstallationSettingsSource()` → add `Optional<Source>
installationSettingsSource()`
- `getProjectSettingsSource()` → add `Optional<Source>
projectSettingsSource()`
- `getUserSettingsSource()` → add `Optional<Source> userSettingsSource()`
- `getInterpolationSource()` → add `Optional<UnaryOperator<String>>
interpolationSource()`
### `maven-api-core` — `org.apache.maven.api.services.xml`
**`XmlReaderRequest`**
- `getPath()` → add `Path path()`
- `getRootDirectory()` → add `Path rootDirectory()`
- `getURL()` → add `URL url()` (note: acronym, keep lowercase `url()` per
Java convention, matching `RemoteRepository.url()`)
- `getInputStream()` → add `InputStream inputStream()`
- `getReader()` → add `Reader reader()`
- `getTransformer()` → add `Transformer transformer()`
- `isStrict()` → add `boolean strict()`
- `getModelId()` → add `String modelId()`
- `getLocation()` → add `String location()`
- `isAddDefaultEntities()` → add `boolean addDefaultEntities()`
## Implementation Pattern
Exact pattern from `Repository.java`:
```java
// New noun-style accessor (canonical, abstract)
@Nonnull
String id();
// Old getter kept as deprecated default delegating to the new accessor
@Nonnull
@Deprecated(since = "4.1.0", forRemoval = true)
default String getId() {
return id();
}
```
For `boolean` properties using `isXxx()`:
```java
// New noun-style accessor
boolean snapshot();
// Old getter deprecated
@Deprecated(since = "4.1.0", forRemoval = true)
default boolean isSnapshot() {
return snapshot();
}
```
For the builder inner classes and their concrete implementations (e.g.
`ArtifactDeployerRequest` has a static inner `ArtifactDeployerRequestBuilder`),
the builder class's concrete implementations of the getters should be updated
to also implement the new noun-style methods, or the deprecated defaults on the
interface will suffice.
## Acceptance Criteria
- All listed `@Immutable` interfaces have noun-style accessor methods added.
- All old `getXxx()` / `isXxx()` methods on those interfaces are retained as
`@Deprecated(since = "4.1.0", forRemoval = true)` `default` methods delegating
to the new accessor.
- Existing callers of old getters continue to compile (binary + source
compat preserved).
- `Packaging.language()` body updated from `type().getLanguage()` to
`type().language()`.
- Any internal Maven code that calls the old getters on these interfaces
should be updated to use the new noun-style accessors (the deprecated wrappers
exist for external consumers, not for in-tree code).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]