1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.repository
;
13 import java
.util
.Collection
;
14 import java
.util
.Collections
;
16 import org
.eclipse
.aether
.RepositorySystemSession
;
17 import org
.eclipse
.aether
.artifact
.Artifact
;
20 * A request to register an artifact within the local repository. Certain local repository implementations can refuse to
21 * serve physically present artifacts if those haven't been previously registered to them.
23 * @see LocalRepositoryManager#add(RepositorySystemSession, LocalArtifactRegistration)
25 public final class LocalArtifactRegistration
28 private Artifact artifact
;
30 private RemoteRepository repository
;
32 private Collection
<String
> contexts
= Collections
.emptyList();
35 * Creates an uninitialized registration.
37 public LocalArtifactRegistration()
39 // enables default constructor
43 * Creates a registration request for the specified (locally installed) artifact.
45 * @param artifact The artifact to register, may be {@code null}.
47 public LocalArtifactRegistration( Artifact artifact
)
49 setArtifact( artifact
);
53 * Creates a registration request for the specified artifact.
55 * @param artifact The artifact to register, may be {@code null}.
56 * @param repository The remote repository from which the artifact was resolved or {@code null} if the artifact was
58 * @param contexts The resolution contexts, may be {@code null}.
60 public LocalArtifactRegistration( Artifact artifact
, RemoteRepository repository
, Collection
<String
> contexts
)
62 setArtifact( artifact
);
63 setRepository( repository
);
64 setContexts( contexts
);
68 * Gets the artifact to register.
70 * @return The artifact or {@code null} if not set.
72 public Artifact
getArtifact()
78 * Sets the artifact to register.
80 * @param artifact The artifact, may be {@code null}.
81 * @return This request for chaining, never {@code null}.
83 public LocalArtifactRegistration
setArtifact( Artifact artifact
)
85 this.artifact
= artifact
;
90 * Gets the remote repository from which the artifact was resolved.
92 * @return The remote repository or {@code null} if the artifact was locally installed.
94 public RemoteRepository
getRepository()
100 * Sets the remote repository from which the artifact was resolved.
102 * @param repository The remote repository or {@code null} if the artifact was locally installed.
103 * @return This request for chaining, never {@code null}.
105 public LocalArtifactRegistration
setRepository( RemoteRepository repository
)
107 this.repository
= repository
;
112 * Gets the resolution contexts in which the artifact is available.
114 * @return The resolution contexts in which the artifact is available, never {@code null}.
116 public Collection
<String
> getContexts()
122 * Sets the resolution contexts in which the artifact is available.
124 * @param contexts The resolution contexts, may be {@code null}.
125 * @return This request for chaining, never {@code null}.
127 public LocalArtifactRegistration
setContexts( Collection
<String
> contexts
)
129 if ( contexts
!= null )
131 this.contexts
= contexts
;
135 this.contexts
= Collections
.emptyList();