]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRegistration.java
Package W3C SAC
[gpl/argeo-slc.git] / org.argeo.slc.repo / src / org / eclipse / aether / repository / LocalMetadataRegistration.java
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
7 *
8 * Contributors:
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.aether.repository;
12
13 import java.util.Collection;
14 import java.util.Collections;
15
16 import org.eclipse.aether.RepositorySystemSession;
17 import org.eclipse.aether.metadata.Metadata;
18
19 /**
20 * A request to register metadata within the local repository.
21 *
22 * @see LocalRepositoryManager#add(RepositorySystemSession, LocalMetadataRegistration)
23 */
24 public final class LocalMetadataRegistration
25 {
26
27 private Metadata metadata;
28
29 private RemoteRepository repository;
30
31 private Collection<String> contexts = Collections.emptyList();
32
33 /**
34 * Creates an uninitialized registration.
35 */
36 public LocalMetadataRegistration()
37 {
38 // enables default constructor
39 }
40
41 /**
42 * Creates a registration request for the specified metadata accompanying a locally installed artifact.
43 *
44 * @param metadata The metadata to register, may be {@code null}.
45 */
46 public LocalMetadataRegistration( Metadata metadata )
47 {
48 setMetadata( metadata );
49 }
50
51 /**
52 * Creates a registration request for the specified metadata.
53 *
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}.
58 */
59 public LocalMetadataRegistration( Metadata metadata, RemoteRepository repository, Collection<String> contexts )
60 {
61 setMetadata( metadata );
62 setRepository( repository );
63 setContexts( contexts );
64 }
65
66 /**
67 * Gets the metadata to register.
68 *
69 * @return The metadata or {@code null} if not set.
70 */
71 public Metadata getMetadata()
72 {
73 return metadata;
74 }
75
76 /**
77 * Sets the metadata to register.
78 *
79 * @param metadata The metadata, may be {@code null}.
80 * @return This request for chaining, never {@code null}.
81 */
82 public LocalMetadataRegistration setMetadata( Metadata metadata )
83 {
84 this.metadata = metadata;
85 return this;
86 }
87
88 /**
89 * Gets the remote repository from which the metadata was resolved.
90 *
91 * @return The remote repository or {@code null} if the metadata was locally installed.
92 */
93 public RemoteRepository getRepository()
94 {
95 return repository;
96 }
97
98 /**
99 * Sets the remote repository from which the metadata was resolved.
100 *
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}.
103 */
104 public LocalMetadataRegistration setRepository( RemoteRepository repository )
105 {
106 this.repository = repository;
107 return this;
108 }
109
110 /**
111 * Gets the resolution contexts in which the metadata is available.
112 *
113 * @return The resolution contexts in which the metadata is available, never {@code null}.
114 */
115 public Collection<String> getContexts()
116 {
117 return contexts;
118 }
119
120 /**
121 * Sets the resolution contexts in which the metadata is available.
122 *
123 * @param contexts The resolution contexts, may be {@code null}.
124 * @return This request for chaining, never {@code null}.
125 */
126 public LocalMetadataRegistration setContexts( Collection<String> contexts )
127 {
128 if ( contexts != null )
129 {
130 this.contexts = contexts;
131 }
132 else
133 {
134 this.contexts = Collections.emptyList();
135 }
136 return this;
137 }
138
139 }