Skip to content

Commit f359b0b

Browse files
committed
API Improvements
1 parent f1b7bf2 commit f359b0b

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

api/maven-api-core/src/main/java/org/apache/maven/api/services/PathSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public Path getPath() {
4242

4343
@Nonnull
4444
@Override
45-
public InputStream getInputStream() throws IOException {
45+
public InputStream openStream() throws IOException {
4646
return Files.newInputStream(path);
4747
}
4848

api/maven-api-core/src/main/java/org/apache/maven/api/services/Source.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,28 @@ public interface Source {
4848
/**
4949
* Provides access the file to be parsed, if this source is backed by a file.
5050
*
51-
* @return The underlying {@code Path}, or {@code null} if this source is not backed by a file.
51+
* @return the underlying {@code Path}, or {@code null} if this source is not backed by a file
5252
*/
5353
@Nullable
5454
Path getPath();
5555

5656
/**
57-
* Gets a byte stream to the source contents. Closing the returned stream is the responsibility of the caller.
57+
* Creates a new byte stream to the source contents.
58+
* Closing the returned stream is the responsibility of the caller.
5859
*
59-
* @return A byte stream to the source contents, never {@code null}.
60+
* @return a byte stream to the source contents, never {@code null}
6061
* @throws IOException in case of IO issue
6162
*/
6263
@Nonnull
63-
InputStream getInputStream() throws IOException;
64+
InputStream openStream() throws IOException;
6465

6566
/**
66-
* Provides a user-friendly hint about the location of the source. This could be a local file path, a URI or just an
67-
* empty string. The intention is to assist users during error reporting.
67+
* Provides a user-friendly hint about the location of the source.
68+
* This could be a local file path, a URI or just an empty string.
69+
* The intention is to assist users during error reporting.
6870
*
69-
* @return A user-friendly hint about the location of the source, never {@code null}.
71+
* @return a user-friendly hint about the location of the source, never {@code null}
7072
*/
71-
@Nullable
73+
@Nonnull
7274
String getLocation();
7375
}

api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ModelParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ public interface ModelParser {
3939
* Locates the pom in the given directory.
4040
*
4141
* @param dir the directory to locate the pom for, never {@code null}
42-
* @return the located pom or <code>null</code> if none was found by this parser
42+
* @return a {@code Source} pointing to the located pom or an empty {@code Optional} if none was found by this parser
4343
*/
4444
@Nonnull
4545
Optional<Source> locate(@Nonnull Path dir);
4646

4747
/**
48-
* Parse the model.
48+
* Parse the model obtained previously by a previous call to {@link #locate(Path)}.
49+
*
4950
*
5051
* @param source the source to parse, never {@code null}
5152
* @param options possible parsing options, may be {@code null}

maven-core/src/main/java/org/apache/maven/internal/impl/DefaultProjectBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public ProjectBuilderResult build(ProjectBuilderRequest request)
8585
ModelSource modelSource = new ModelSource() {
8686
@Override
8787
public InputStream getInputStream() throws IOException {
88-
return source.getInputStream();
88+
return source.openStream();
8989
}
9090

9191
@Override

maven-core/src/main/java/org/apache/maven/internal/impl/DefaultSettingsBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private static class MappedSettingsSource implements SettingsSource {
108108

109109
@Override
110110
public InputStream getInputStream() throws IOException {
111-
return source.getInputStream();
111+
return source.openStream();
112112
}
113113

114114
@Override

maven-core/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static class MappedToolchainsSource implements org.apache.maven.building
9595

9696
@Override
9797
public InputStream getInputStream() throws IOException {
98-
return source.getInputStream();
98+
return source.openStream();
9999
}
100100

101101
@Override

maven-model-builder/src/main/java/org/apache/maven/model/building/FileSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public Path getPath() {
3636
}
3737

3838
@Override
39-
public InputStream getInputStream() throws IOException {
39+
public InputStream openStream() throws IOException {
4040
return Files.newInputStream(pom);
4141
}
4242

0 commit comments

Comments
 (0)