Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ static class ResolvedPathSource extends PathSource implements ModelSource {
}

@Override
@Nullable
public Path getPath() {
return null;
}

@Override
@Nullable
public Source resolve(String relative) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public Path getRootDirectory() {
}

@Override
@Nullable
public URL getURL() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,13 @@ private record Impl(
}

@Override
@Nullable
public String attribute(@Nonnull String name) {
return attributes.get(name);
}

@Override
@Nullable
public XmlNode child(String name) {
if (name != null) {
ListIterator<XmlNode> it = children.listIterator(children.size());
Expand Down
4 changes: 4 additions & 0 deletions compat/maven-artifact/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ under the License.
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Objects;
import java.util.WeakHashMap;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;

Expand Down Expand Up @@ -92,6 +93,7 @@ public VersionRange cloneOf() {
* @return a new {@link VersionRange} object that represents the spec
* @throws InvalidVersionSpecificationException if invalid version specification
*/
@Nullable
public static VersionRange createFromVersionSpec(String spec) throws InvalidVersionSpecificationException {
if (spec == null) {
return null;
Expand Down Expand Up @@ -202,6 +204,7 @@ private static Restriction parseRestriction(String spec) throws InvalidVersionSp
return restriction;
}

@Nullable
public static VersionRange createFromVersion(String version) {
if (DefaultArtifact.empty(version)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
import java.io.File;
import java.nio.file.Paths;

import org.apache.maven.api.annotations.Nullable;

/**
* Resolve relative file path against the given base directory
*/
@Deprecated
public class ResolveFile {

@Nullable
public static File resolveFile(File file, String baseDirectory) {
if (file == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.PrintStream;

import org.apache.maven.api.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.Marker;

Expand Down Expand Up @@ -61,6 +62,7 @@ public void error(String msg, Throwable t) {
//
// Don't need any of this
//
@Nullable
public String getName() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.Set;
import java.util.function.UnaryOperator;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.impl.model.DefaultInterpolator;

/**
Expand Down Expand Up @@ -272,6 +273,7 @@ void putAllSubstituted(Map<? extends String, ? extends String> m) {
storage.putAll(m);
}

@Nullable
public String put(String key, List<String> commentLines, List<String> valueLines) {
commentLines = new ArrayList<>(commentLines);
valueLines = new ArrayList<>(valueLines);
Expand Down Expand Up @@ -305,6 +307,7 @@ public String put(String key, List<String> commentLines, List<String> valueLines
return storage.put(key, property[1]);
}

@Nullable
public String put(String key, List<String> commentLines, String value) {
commentLines = new ArrayList<>(commentLines);
this.layout.put(key, new Layout(commentLines, null));
Expand Down Expand Up @@ -843,6 +846,7 @@ public PropertiesReader(Reader reader, boolean maybeTyped) {
*
* @throws IOException in case of an I/O error
*/
@Nullable
public String readProperty() throws IOException {
commentLines.clear();
valueLines.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Map;
import java.util.Objects;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;

Expand Down Expand Up @@ -81,11 +82,13 @@ public DefaultModelBuildingResult addModelId(String modelId) {
}

@Override
@Nullable
public Model getRawModel() {
return rawModels.get(modelIds.get(0));
}

@Override
@Nullable
public Model getRawModel(String modelId) {
return rawModels.get(modelId);
}
Expand All @@ -100,6 +103,7 @@ public DefaultModelBuildingResult setRawModel(String modelId, Model rawModel) {
}

@Override
@Nullable
public List<Profile> getActivePomProfiles(String modelId) {
return activePomProfiles.get(modelId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.nio.file.Files;
import java.nio.file.Path;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.building.FileSource;

/**
Expand Down Expand Up @@ -58,6 +59,7 @@ public File getPomFile() {
}

@Override
@Nullable
public ModelSource2 getRelatedSource(String relPath) {
relPath = relPath.replace('\\', File.separatorChar).replace('/', File.separatorChar);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collections;
import java.util.List;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.model.Model;

/**
Expand Down Expand Up @@ -87,6 +88,7 @@ public ModelBuildingResult getResult() {
*
* @return The erroneous model or {@code null} if not available.
*/
@Nullable
public Model getModel() {
if (result == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Date;
import java.util.Properties;

import org.apache.maven.api.annotations.Nullable;
import org.codehaus.plexus.interpolation.AbstractValueSource;

/**
Expand All @@ -36,6 +37,7 @@ class BuildTimestampValueSource extends AbstractValueSource {
}

@Override
@Nullable
public Object getValue(String expression) {
if ("build.timestamp".equals(expression) || "maven.build.timestamp".equals(expression)) {
return mavenBuildTimestamp.formattedTimestamp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* limitations under the License.
*/

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.model.interpolation.reflection.ReflectionValueExtractor;
import org.codehaus.plexus.interpolation.AbstractValueSource;

Expand Down Expand Up @@ -71,6 +72,7 @@ public ObjectBasedValueSource(Object root) {
* <p><b>NOTE:</b> The object-graph navigation actually takes place via the
* {@link ReflectionValueExtractor} class.</p>
*/
@Nullable
public Object getValue(String expression) {
if (expression == null || expression.trim().isEmpty()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Collection;
import java.util.List;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.model.path.PathTranslator;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.util.ValueSourceUtils;
Expand Down Expand Up @@ -50,6 +51,7 @@ class PathTranslatingPostProcessor implements InterpolationPostProcessor {
}

@Override
@Nullable
public Object execute(String expression, Object value) {
if (value != null) {
expression = ValueSourceUtils.trimPrefix(expression, expressionPrefixes, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.ModelBuildingRequest;
Expand Down Expand Up @@ -124,6 +125,7 @@ private static final class InterpolateObjectAction {
this.problems = problems;
}

@Nullable
public Object run() {
while (!interpolationTargets.isEmpty()) {
Object obj = interpolationTargets.removeFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashSet;
import java.util.Set;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.model.path.UrlNormalizer;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;

Expand Down Expand Up @@ -52,6 +53,7 @@ class UrlNormalizingPostProcessor implements InterpolationPostProcessor {
}

@Override
@Nullable
public Object execute(String expression, Object value) {
if (value != null && URL_EXPRESSIONS.contains(expression)) {
return normalizer.normalize(value.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.util.Hashtable;
import java.util.Map;

import org.apache.maven.api.annotations.Nullable;

/**
* A cache of introspection information for a specific class instance.
* Keys {@link Method} objects by a concatenation of the
Expand Down Expand Up @@ -81,6 +83,7 @@ Class<?> getCachedClass() {
* @return The found method.
* @throws MethodMap.AmbiguousException in case of duplicate methods.
*/
@Nullable
public Method findMethod(String name, Object... params) throws MethodMap.AmbiguousException {
String methodKey = makeMethodKey(name, params);
Object cacheEntry = methodCache.get(methodKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public int skipChar() {
return idx < expression.length() ? expression.charAt(idx++) : EOF;
}

@Nullable
public String nextToken(char delimiter) {
int start = idx;

Expand All @@ -97,6 +98,7 @@ public String nextToken(char delimiter) {
return expression.substring(start, idx++);
}

@Nullable
public String nextPropertyName() {
final int start = idx;

Expand Down Expand Up @@ -162,6 +164,7 @@ public static Object evaluate(@Nonnull String expression, @Nullable Object root)
* @return the object defined by the expression
* @throws IntrospectionException if any
*/
@Nullable
public static Object evaluate(@Nonnull String expression, @Nullable Object root, boolean trimRootToken)
throws IntrospectionException {
Object value = root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.nio.file.Path;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.model.ActivationFile;
import org.apache.maven.model.profile.ProfileActivationContext;
import org.apache.maven.model.root.RootLocator;
Expand Down Expand Up @@ -64,6 +65,7 @@ public ProfileActivationFilePathInterpolator setRootLocator(RootLocator rootLoca
*
* @return absolute path or {@code null} if the input was {@code null}
*/
@Nullable
public String interpolate(String path, ProfileActivationContext context) throws InterpolationException {
if (path == null) {
return null;
Expand All @@ -75,7 +77,9 @@ public String interpolate(String path, ProfileActivationContext context) throws

if (basedir != null) {
interpolator.addValueSource(new AbstractValueSource(false) {

@Override
@Nullable
public Object getValue(String expression) {
if ("basedir".equals(expression) || "project.basedir".equals(expression)) {
return basedir.getAbsolutePath();
Expand All @@ -88,7 +92,9 @@ public Object getValue(String expression) {
}

interpolator.addValueSource(new AbstractValueSource(false) {

@Override
@Nullable
public Object getValue(String expression) {
if ("project.rootDirectory".equals(expression)) {
Path base = basedir != null ? basedir.toPath() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.maven.model.building;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Repository;
Expand Down Expand Up @@ -111,11 +112,13 @@ public ModelSource resolveModel(String groupId, String artifactId, String versio
}

@Override
@Nullable
public ModelSource resolveModel(Parent parent) throws UnresolvableModelException {
return null;
}

@Override
@Nullable
public ModelSource resolveModel(Dependency dependency) throws UnresolvableModelException {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.apache.maven.api.annotations.Nullable;
import org.apache.maven.api.plugin.descriptor.lifecycle.Lifecycle;
import org.apache.maven.api.plugin.descriptor.lifecycle.LifecycleConfiguration;
import org.apache.maven.artifact.Artifact;
Expand Down Expand Up @@ -320,6 +321,7 @@ public int hashCode() {
return 10 + getId().hashCode();
}

@Nullable
public MojoDescriptor getMojo(String goal) {
if (getMojos() == null) {
return null; // no mojo in this POM
Expand Down Expand Up @@ -415,6 +417,7 @@ public void setPluginArtifact(Artifact pluginArtifact) {
this.pluginArtifact = pluginArtifact;
}

@Nullable
public Lifecycle getLifecycleMapping(String lifecycleId) throws IOException, XMLStreamException {
return getLifecycleMappings().get(lifecycleId);
}
Expand Down
Loading