Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed @NotNull to Validate.notNull() in Aether.jara #80

Merged
merged 2 commits into from
Feb 16, 2016
Merged
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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kuali.maven.wagons</groupId>
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/jcabi/aether/Aether.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.io.filefilter.NameFileFilter;
Expand Down Expand Up @@ -121,7 +120,7 @@ public final class Aether {
* @param prj The Maven project
* @param repo Local repository location (directory path)
*/
public Aether(@NotNull final MavenProject prj, @NotNull final File repo) {
public Aether(final MavenProject prj, final File repo) {
this(prj.getRemoteProjectRepositories(), repo);
}

Expand All @@ -133,8 +132,8 @@ public Aether(@NotNull final MavenProject prj, @NotNull final File repo) {
* @since 0.8
*/
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public Aether(@NotNull final Collection<RemoteRepository> repos,
@NotNull final File repo) {
public Aether(final Collection<RemoteRepository> repos,
final File repo) {
final Collection<Repository> rlist = new LinkedList<Repository>();
for (final RemoteRepository remote : this.prepos(this.mrepos(repos))) {
rlist.add(new Repository(remote));
Expand All @@ -150,8 +149,8 @@ public Aether(@NotNull final Collection<RemoteRepository> repos,
* @return The list of dependencies
* @throws DependencyResolutionException If can't fetch it
*/
public List<Artifact> resolve(@NotNull final Artifact root,
@NotNull final String scope) throws DependencyResolutionException {
public List<Artifact> resolve(final Artifact root,
final String scope) throws DependencyResolutionException {
final DependencyFilter filter =
DependencyFilterUtils.classpathFilter(scope);
if (filter == null) {
Expand All @@ -170,8 +169,8 @@ public List<Artifact> resolve(@NotNull final Artifact root,
* @return The list of dependencies
* @throws DependencyResolutionException If can't fetch it
*/
public List<Artifact> resolve(@NotNull final Artifact root,
@NotNull final String scope, @NotNull final DependencyFilter filter)
public List<Artifact> resolve(final Artifact root,
final String scope, final DependencyFilter filter)
throws DependencyResolutionException {
final Dependency rdep = new Dependency(root, scope);
final CollectRequest crq = this.request(rdep);
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/jcabi/aether/Classpath.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
Expand Down Expand Up @@ -107,8 +106,8 @@ public final class Classpath extends AbstractSet<File> {
* @param repo Local repository location (directory path)
* @param scp The scope to use, e.g. "runtime" or "compile"
*/
public Classpath(@NotNull final MavenProject prj,
@NotNull final File repo, @NotNull final String scp) {
public Classpath(final MavenProject prj, final File repo,
final String scp) {
this(prj, repo, Arrays.asList(scp));
}

Expand All @@ -118,8 +117,8 @@ public Classpath(@NotNull final MavenProject prj,
* @param repo Local repository location (directory path)
* @param scps All scopes to include
*/
public Classpath(@NotNull final MavenProject prj,
@NotNull final File repo, @NotNull final Collection<String> scps) {
public Classpath(final MavenProject prj,
final File repo, final Collection<String> scps) {
super();
this.project = prj;
this.aether = new Aether(prj, repo);
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/jcabi/aether/MavenClasspath.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
Expand Down Expand Up @@ -115,9 +114,8 @@ public final class MavenClasspath extends AbstractSet<File> {
* @param sess Maven session.
* @param scp The scope to use, e.g. "runtime" or "compile"
*/
public MavenClasspath(@NotNull final DependencyGraphBuilder bldr,
@NotNull final MavenSession sess,
@NotNull final String scp) {
public MavenClasspath(final DependencyGraphBuilder bldr,
final MavenSession sess, final String scp) {
this(bldr, sess, Arrays.asList(scp));
}

Expand All @@ -127,9 +125,8 @@ public MavenClasspath(@NotNull final DependencyGraphBuilder bldr,
* @param sess Maven session.
* @param scps All scopes to include
*/
public MavenClasspath(@NotNull final DependencyGraphBuilder bldr,
@NotNull final MavenSession sess,
@NotNull final Collection<String> scps) {
public MavenClasspath(final DependencyGraphBuilder bldr,
final MavenSession sess, final Collection<String> scps) {
super();
this.builder = bldr;
this.session = sess;
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/com/jcabi/aether/MavenRootArtifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.jcabi.log.Logger;
import java.util.Collection;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Exclusion;
Expand All @@ -51,19 +50,16 @@ final class MavenRootArtifact {
/**
* The artifact.
*/
@NotNull
private final transient Artifact art;

/**
* Exclusions.
*/
@NotNull
private final transient Collection<Exclusion> exclusions;

/**
* This artifact child artifacts.
*/
@NotNull
private final transient Collection<Artifact> chldrn;

/**
Expand All @@ -72,9 +68,8 @@ final class MavenRootArtifact {
* @param excl Exclusions
* @param chld Child artifacts
*/
protected MavenRootArtifact(@NotNull final Artifact artifact,
@NotNull final List<Exclusion> excl,
@NotNull final Collection<Artifact> chld) {
protected MavenRootArtifact(final Artifact artifact,
final List<Exclusion> excl, final Collection<Artifact> chld) {
this.art = artifact;
this.exclusions = excl;
this.chldrn = chld;
Expand Down Expand Up @@ -127,7 +122,7 @@ public Collection<Artifact> children() {
* @param artifact The artifact to check
* @return TRUE if it should be excluded
*/
public boolean excluded(@NotNull final Artifact artifact) {
public boolean excluded(final Artifact artifact) {
boolean excluded = false;
for (final Exclusion exclusion : this.exclusions) {
if (exclusion.getArtifactId().equals(artifact.getArtifactId())
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/com/jcabi/aether/RootArtifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.jcabi.log.Logger;
import java.util.Collection;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import org.apache.maven.model.Exclusion;
import org.sonatype.aether.artifact.Artifact;
Expand All @@ -55,19 +54,16 @@ final class RootArtifact {
/**
* The aether for finding children.
*/
@NotNull
private final transient Aether aether;

/**
* The artifact.
*/
@NotNull
private final transient Artifact art;

/**
* Exclusions.
*/
@NotNull
private final transient Collection<Exclusion> exclusions;

/**
Expand All @@ -76,9 +72,8 @@ final class RootArtifact {
* @param artifact The artifact
* @param excl Exclusions
*/
protected RootArtifact(@NotNull final Aether aeth,
@NotNull final Artifact artifact,
@NotNull final Collection<Exclusion> excl) {
protected RootArtifact(final Aether aeth,
final Artifact artifact, final Collection<Exclusion> excl) {
this.aether = aeth;
this.art = artifact;
this.exclusions = excl;
Expand Down Expand Up @@ -138,7 +133,7 @@ this.art, JavaScopes.COMPILE, new NonOptionalFilter()
* @param artifact The artifact to check
* @return TRUE if it should be excluded
*/
public boolean excluded(@NotNull final Artifact artifact) {
public boolean excluded(final Artifact artifact) {
boolean excluded = false;
for (final Exclusion exclusion : this.exclusions) {
if (exclusion.getArtifactId().equals(artifact.getArtifactId())
Expand Down
39 changes: 0 additions & 39 deletions src/test/java/com/jcabi/aether/AetherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,45 +165,6 @@ public Void call() throws Exception {
svc.shutdown();
}

/**
* Aether can reject NULL Maven project.
* @throws Exception If there is some problem inside
*/
@Test(expected = javax.validation.ConstraintViolationException.class)
public void rejectsNullMavenProject() throws Exception {
final MavenProject project = null;
new Aether(project, this.temp.newFolder());
}

/**
* Aether can reject NULL repository path.
* @throws Exception If there is some problem inside
*/
@Test(expected = javax.validation.ConstraintViolationException.class)
public void rejectsNullRepoPath() throws Exception {
new Aether(this.project(), null);
}

/**
* Aether can reject NULL artifact.
* @throws Exception If there is some problem inside
*/
@Test(expected = javax.validation.ConstraintViolationException.class)
public void rejectsNullArtifact() throws Exception {
new Aether(this.project(), this.temp.newFolder())
.resolve(null, JavaScopes.RUNTIME);
}

/**
* Aether can reject NULL scope.
* @throws Exception If there is some problem inside
*/
@Test(expected = javax.validation.ConstraintViolationException.class)
public void rejectsNullScope() throws Exception {
new Aether(this.project(), this.temp.newFolder())
.resolve(new DefaultArtifact("junit:junit:4.10"), null);
}

/**
* Aether can throw on non-found artifact.
* @throws Exception If there is some problem inside
Expand Down