]>
git.argeo.org Git - gpl/argeo-slc.git/blob - cms/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
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.installation
;
13 import java
.util
.ArrayList
;
14 import java
.util
.Collection
;
15 import java
.util
.Collections
;
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
;
23 * The result of installing artifacts and their accompanying metadata into the a remote repository.
25 * @see RepositorySystem#install(RepositorySystemSession, InstallRequest)
27 public final class InstallResult
30 private final InstallRequest request
;
32 private Collection
<Artifact
> artifacts
;
34 private Collection
<Metadata
> metadata
;
37 * Creates a new result for the specified request.
39 * @param request The installation request, must not be {@code null}.
41 public InstallResult( InstallRequest request
)
43 if ( request
== null )
45 throw new IllegalArgumentException( "install request has not been specified" );
47 this.request
= request
;
48 artifacts
= Collections
.emptyList();
49 metadata
= Collections
.emptyList();
53 * Gets the install request that was made.
55 * @return The install request, never {@code null}.
57 public InstallRequest
getRequest()
63 * Gets the artifacts that got installed.
65 * @return The installed artifacts, never {@code null}.
67 public Collection
<Artifact
> getArtifacts()
73 * Sets the artifacts that got installed.
75 * @param artifacts The installed artifacts, may be {@code null}.
76 * @return This result for chaining, never {@code null}.
78 public InstallResult
setArtifacts( Collection
<Artifact
> artifacts
)
80 if ( artifacts
== null )
82 this.artifacts
= Collections
.emptyList();
86 this.artifacts
= artifacts
;
92 * Adds the specified artifacts to the result.
94 * @param artifact The installed artifact to add, may be {@code null}.
95 * @return This result for chaining, never {@code null}.
97 public InstallResult
addArtifact( Artifact artifact
)
99 if ( artifact
!= null )
101 if ( artifacts
.isEmpty() )
103 artifacts
= new ArrayList
<Artifact
>();
105 artifacts
.add( artifact
);
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.
114 * @return The installed metadata, never {@code null}.
116 public Collection
<Metadata
> getMetadata()
122 * Sets the metadata that got installed.
124 * @param metadata The installed metadata, may be {@code null}.
125 * @return This result for chaining, never {@code null}.
127 public InstallResult
setMetadata( Collection
<Metadata
> metadata
)
129 if ( metadata
== null )
131 this.metadata
= Collections
.emptyList();
135 this.metadata
= metadata
;
141 * Adds the specified metadata to this result.
143 * @param metadata The installed metadata to add, may be {@code null}.
144 * @return This result for chaining, never {@code null}.
146 public InstallResult
addMetadata( Metadata metadata
)
148 if ( metadata
!= null )
150 if ( this.metadata
.isEmpty() )
152 this.metadata
= new ArrayList
<Metadata
>();
154 this.metadata
.add( metadata
);
160 public String
toString()
162 return getArtifacts() + ", " + getMetadata();