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

michaelo pushed a commit to branch MRESOLVER-233
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit 106582db17fe11ab28c74da1f2eb0381eab7c3f1
Author: Michael Osipov <[email protected]>
AuthorDate: Thu Dec 30 15:28:51 2021 +0100

    [MRESOLVER-233] Make org.e.a.artifact.AbstractArtifact.newInstance() 
protected abstract
---
 .../eclipse/aether/artifact/AbstractArtifact.java  | 18 ++++++----------
 .../eclipse/aether/artifact/DefaultArtifact.java   | 25 ++++++++++++++--------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git 
a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
 
b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
index f18b398..7a9fab9 100644
--- 
a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
+++ 
b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
@@ -8,9 +8,9 @@ package org.eclipse.aether.artifact;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -90,18 +90,14 @@ public abstract class AbstractArtifact
 
     /**
      * Creates a new artifact with the specified coordinates, properties and 
file.
-     * 
+     *
      * @param version The version of the artifact, may be {@code null}.
      * @param properties The properties of the artifact, may be {@code null} 
if none. The method may assume immutability
      *            of the supplied map, i.e. need not copy it.
      * @param file The resolved file of the artifact, may be {@code null}.
      * @return The new artifact instance, never {@code null}.
      */
-    private Artifact newInstance( String version, Map<String, String> 
properties, File file )
-    {
-        return new DefaultArtifact( getGroupId(), getArtifactId(), 
getClassifier(), getExtension(), version, file,
-                                    properties );
-    }
+    protected abstract Artifact newInstance( String version, Map<String, 
String> properties, File file );
 
     public Artifact setVersion( String version )
     {
@@ -142,7 +138,7 @@ public abstract class AbstractArtifact
     /**
      * Copies the specified artifact properties. This utility method should be 
used when creating new artifact instances
      * with caller-supplied properties.
-     * 
+     *
      * @param properties The properties to copy, may be {@code null}.
      * @return The copied and read-only properties, never {@code null}.
      */
@@ -175,7 +171,7 @@ public abstract class AbstractArtifact
 
     /**
      * Compares this artifact with the specified object.
-     * 
+     *
      * @param obj The object to compare this artifact against, may be {@code 
null}.
      * @return {@code true} if and only if the specified object is another 
{@link Artifact} with equal coordinates,
      *         properties and file, {@code false} otherwise.
@@ -205,7 +201,7 @@ public abstract class AbstractArtifact
 
     /**
      * Returns a hash code for this artifact.
-     * 
+     *
      * @return A hash code for the artifact.
      */
     @Override
diff --git 
a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java
 
b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java
index f385e2c..bbea252 100644
--- 
a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java
+++ 
b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java
@@ -8,9 +8,9 @@ package org.eclipse.aether.artifact;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -53,7 +53,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates. If not specified 
in the artifact coordinates, the
      * artifact's extension defaults to {@code jar} and classifier to an empty 
string.
-     * 
+     *
      * @param coords The artifact coordinates in the format
      *            {@code 
<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be 
{@code null}.
      *
@@ -68,7 +68,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates and properties. 
If not specified in the artifact
      * coordinates, the artifact's extension defaults to {@code jar} and 
classifier to an empty string.
-     * 
+     *
      * @param coords The artifact coordinates in the format
      *            {@code 
<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be 
{@code null}.
      * @param properties The artifact properties, may be {@code null}.
@@ -101,7 +101,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates and no 
classifier. Passing {@code null} for any of the
      * coordinates is equivalent to specifying an empty string.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code 
null}.
      * @param artifactId The artifact identifier of the artifact, may be 
{@code null}.
      * @param extension The file extension of the artifact, may be {@code 
null}.
@@ -115,7 +115,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates. Passing {@code 
null} for any of the coordinates is
      * equivalent to specifying an empty string.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code 
null}.
      * @param artifactId The artifact identifier of the artifact, may be 
{@code null}.
      * @param classifier The classifier of the artifact, may be {@code null}.
@@ -132,7 +132,7 @@ public final class DefaultArtifact
      * equivalent to specifying an empty string. The optional artifact type 
provided to this constructor will be used to
      * determine the artifact's classifier and file extension if the 
corresponding arguments for this constructor are
      * {@code null}.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code 
null}.
      * @param artifactId The artifact identifier of the artifact, may be 
{@code null}.
      * @param classifier The classifier of the artifact, may be {@code null}.
@@ -152,7 +152,7 @@ public final class DefaultArtifact
      * will be used to determine the artifact's classifier and file extension 
if the corresponding arguments for this
      * constructor are {@code null}. If the artifact type specifies 
properties, those will get merged with the
      * properties passed directly into the constructor, with the latter 
properties taking precedence.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code 
null}.
      * @param artifactId The artifact identifier of the artifact, may be 
{@code null}.
      * @param classifier The classifier of the artifact, may be {@code null}.
@@ -215,7 +215,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates, properties and 
file. Passing {@code null} for any of the
      * coordinates is equivalent to specifying an empty string.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code 
null}.
      * @param artifactId The artifact identifier of the artifact, may be 
{@code null}.
      * @param classifier The classifier of the artifact, may be {@code null}.
@@ -249,6 +249,13 @@ public final class DefaultArtifact
         this.properties = properties;
     }
 
+    @Override
+    protected Artifact newInstance(String version, Map<String, String> 
properties, File file)
+    {
+        return new DefaultArtifact( getGroupId(), getArtifactId(), 
getClassifier(), getExtension(), version, file,
+                                    properties );
+    }
+
     private static String emptify( String str )
     {
         return ( str == null ) ? "" : str;

Reply via email to