]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallResult.java
Start working on migration to new format.
[gpl/argeo-slc.git] / org.argeo.slc.repo / src / org / eclipse / aether / installation / InstallResult.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 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.installation;
12
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.Collections;
16
17 import org.eclipse.aether.RepositorySystem;
18 import org.eclipse.aether.RepositorySystemSession;
19 import org.eclipse.aether.artifact.Artifact;
20 import org.eclipse.aether.metadata.Metadata;
21
22 /**
23 * The result of installing artifacts and their accompanying metadata into the a remote repository.
24 *
25 * @see RepositorySystem#install(RepositorySystemSession, InstallRequest)
26 */
27 public final class InstallResult
28 {
29
30 private final InstallRequest request;
31
32 private Collection<Artifact> artifacts;
33
34 private Collection<Metadata> metadata;
35
36 /**
37 * Creates a new result for the specified request.
38 *
39 * @param request The installation request, must not be {@code null}.
40 */
41 public InstallResult( InstallRequest request )
42 {
43 if ( request == null )
44 {
45 throw new IllegalArgumentException( "install request has not been specified" );
46 }
47 this.request = request;
48 artifacts = Collections.emptyList();
49 metadata = Collections.emptyList();
50 }
51
52 /**
53 * Gets the install request that was made.
54 *
55 * @return The install request, never {@code null}.
56 */
57 public InstallRequest getRequest()
58 {
59 return request;
60 }
61
62 /**
63 * Gets the artifacts that got installed.
64 *
65 * @return The installed artifacts, never {@code null}.
66 */
67 public Collection<Artifact> getArtifacts()
68 {
69 return artifacts;
70 }
71
72 /**
73 * Sets the artifacts that got installed.
74 *
75 * @param artifacts The installed artifacts, may be {@code null}.
76 * @return This result for chaining, never {@code null}.
77 */
78 public InstallResult setArtifacts( Collection<Artifact> artifacts )
79 {
80 if ( artifacts == null )
81 {
82 this.artifacts = Collections.emptyList();
83 }
84 else
85 {
86 this.artifacts = artifacts;
87 }
88 return this;
89 }
90
91 /**
92 * Adds the specified artifacts to the result.
93 *
94 * @param artifact The installed artifact to add, may be {@code null}.
95 * @return This result for chaining, never {@code null}.
96 */
97 public InstallResult addArtifact( Artifact artifact )
98 {
99 if ( artifact != null )
100 {
101 if ( artifacts.isEmpty() )
102 {
103 artifacts = new ArrayList<Artifact>();
104 }
105 artifacts.add( artifact );
106 }
107 return this;
108 }
109
110 /**
111 * Gets the metadata that got installed. Note that due to automatically generated metadata, there might have been
112 * more metadata installed than originally specified in the install request.
113 *
114 * @return The installed metadata, never {@code null}.
115 */
116 public Collection<Metadata> getMetadata()
117 {
118 return metadata;
119 }
120
121 /**
122 * Sets the metadata that got installed.
123 *
124 * @param metadata The installed metadata, may be {@code null}.
125 * @return This result for chaining, never {@code null}.
126 */
127 public InstallResult setMetadata( Collection<Metadata> metadata )
128 {
129 if ( metadata == null )
130 {
131 this.metadata = Collections.emptyList();
132 }
133 else
134 {
135 this.metadata = metadata;
136 }
137 return this;
138 }
139
140 /**
141 * Adds the specified metadata to this result.
142 *
143 * @param metadata The installed metadata to add, may be {@code null}.
144 * @return This result for chaining, never {@code null}.
145 */
146 public InstallResult addMetadata( Metadata metadata )
147 {
148 if ( metadata != null )
149 {
150 if ( this.metadata.isEmpty() )
151 {
152 this.metadata = new ArrayList<Metadata>();
153 }
154 this.metadata.add( metadata );
155 }
156 return this;
157 }
158
159 @Override
160 public String toString()
161 {
162 return getArtifacts() + ", " + getMetadata();
163 }
164
165 }