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
.metadata
.Metadata
;
20 * A request to register metadata within the local repository.
22 * @see LocalRepositoryManager#add(RepositorySystemSession, LocalMetadataRegistration)
24 public final class LocalMetadataRegistration
27 private Metadata metadata
;
29 private RemoteRepository repository
;
31 private Collection
<String
> contexts
= Collections
.emptyList();
34 * Creates an uninitialized registration.
36 public LocalMetadataRegistration()
38 // enables default constructor
42 * Creates a registration request for the specified metadata accompanying a locally installed artifact.
44 * @param metadata The metadata to register, may be {@code null}.
46 public LocalMetadataRegistration( Metadata metadata
)
48 setMetadata( metadata
);
52 * Creates a registration request for the specified metadata.
54 * @param metadata The metadata to register, may be {@code null}.
55 * @param repository The remote repository from which the metadata was resolved or {@code null} if the metadata
56 * accompanies a locally installed artifact.
57 * @param contexts The resolution contexts, may be {@code null}.
59 public LocalMetadataRegistration( Metadata metadata
, RemoteRepository repository
, Collection
<String
> contexts
)
61 setMetadata( metadata
);
62 setRepository( repository
);
63 setContexts( contexts
);
67 * Gets the metadata to register.
69 * @return The metadata or {@code null} if not set.
71 public Metadata
getMetadata()
77 * Sets the metadata to register.
79 * @param metadata The metadata, may be {@code null}.
80 * @return This request for chaining, never {@code null}.
82 public LocalMetadataRegistration
setMetadata( Metadata metadata
)
84 this.metadata
= metadata
;
89 * Gets the remote repository from which the metadata was resolved.
91 * @return The remote repository or {@code null} if the metadata was locally installed.
93 public RemoteRepository
getRepository()
99 * Sets the remote repository from which the metadata was resolved.
101 * @param repository The remote repository or {@code null} if the metadata accompanies a locally installed artifact.
102 * @return This request for chaining, never {@code null}.
104 public LocalMetadataRegistration
setRepository( RemoteRepository repository
)
106 this.repository
= repository
;
111 * Gets the resolution contexts in which the metadata is available.
113 * @return The resolution contexts in which the metadata is available, never {@code null}.
115 public Collection
<String
> getContexts()
121 * Sets the resolution contexts in which the metadata is available.
123 * @param contexts The resolution contexts, may be {@code null}.
124 * @return This request for chaining, never {@code null}.
126 public LocalMetadataRegistration
setContexts( Collection
<String
> contexts
)
128 if ( contexts
!= null )
130 this.contexts
= contexts
;
134 this.contexts
= Collections
.emptyList();