X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.repo%2Fsrc%2Forg%2Feclipse%2Faether%2Fresolution%2FVersionRequest.java;fp=org.argeo.slc.repo%2Fsrc%2Forg%2Feclipse%2Faether%2Fresolution%2FVersionRequest.java;h=e18701be9b77b4f367e824bc05b6bf81bca34a77;hb=825d60c5348dbe3f5be25b0bccf7bdebfe694219;hp=0000000000000000000000000000000000000000;hpb=5e991fff5cba01858dcc5747a27e637325bc5c8e;p=gpl%2Fargeo-jcr.git diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java new file mode 100644 index 0000000..e18701b --- /dev/null +++ b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java @@ -0,0 +1,181 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 Sonatype, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sonatype, Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.aether.resolution; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.repository.RemoteRepository; + +/** + * A request to resolve a metaversion. + * + * @see RepositorySystem#resolveVersion(RepositorySystemSession, VersionRequest) + */ +public final class VersionRequest +{ + + private Artifact artifact; + + private List repositories = Collections.emptyList(); + + private String context = ""; + + private RequestTrace trace; + + /** + * Creates an uninitialized request. + */ + public VersionRequest() + { + // enables default constructor + } + + /** + * Creates a request with the specified properties. + * + * @param artifact The artifact whose (meta-)version should be resolved, may be {@code null}. + * @param repositories The repositories to resolve the version from, may be {@code null}. + * @param context The context in which this request is made, may be {@code null}. + */ + public VersionRequest( Artifact artifact, List repositories, String context ) + { + setArtifact( artifact ); + setRepositories( repositories ); + setRequestContext( context ); + } + + /** + * Gets the artifact whose (meta-)version shall be resolved. + * + * @return The artifact or {@code null} if not set. + */ + public Artifact getArtifact() + { + return artifact; + } + + /** + * Sets the artifact whose (meta-)version shall be resolved. + * + * @param artifact The artifact, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public VersionRequest setArtifact( Artifact artifact ) + { + this.artifact = artifact; + return this; + } + + /** + * Gets the repositories to resolve the version from. + * + * @return The repositories, never {@code null}. + */ + public List getRepositories() + { + return repositories; + } + + /** + * Sets the repositories to resolve the version from. + * + * @param repositories The repositories, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public VersionRequest setRepositories( List repositories ) + { + if ( repositories == null ) + { + this.repositories = Collections.emptyList(); + } + else + { + this.repositories = repositories; + } + return this; + } + + /** + * Adds the specified repository for the resolution. + * + * @param repository The repository to add, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public VersionRequest addRepository( RemoteRepository repository ) + { + if ( repository != null ) + { + if ( this.repositories.isEmpty() ) + { + this.repositories = new ArrayList(); + } + this.repositories.add( repository ); + } + return this; + } + + /** + * Gets the context in which this request is made. + * + * @return The context, never {@code null}. + */ + public String getRequestContext() + { + return context; + } + + /** + * Sets the context in which this request is made. + * + * @param context The context, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public VersionRequest setRequestContext( String context ) + { + this.context = ( context != null ) ? context : ""; + return this; + } + + /** + * Gets the trace information that describes the higher level request/operation in which this request is issued. + * + * @return The trace information about the higher level operation or {@code null} if none. + */ + public RequestTrace getTrace() + { + return trace; + } + + /** + * Sets the trace information that describes the higher level request/operation in which this request is issued. + * + * @param trace The trace information about the higher level operation, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public VersionRequest setTrace( RequestTrace trace ) + { + this.trace = trace; + return this; + } + + @Override + public String toString() + { + return getArtifact() + " < " + getRepositories(); + } + +}