o Refactored code

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@805960 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-19 20:19:07 +00:00
parent 90333e8cd9
commit 68ca923fb5
2 changed files with 34 additions and 27 deletions

View File

@ -39,6 +39,27 @@ public class DefaultRepositoryRequest
private RepositoryCache cache;
/**
* Creates an empty repository request.
*/
public DefaultRepositoryRequest()
{
// enables no-arg constructor
}
/**
* Creates a shallow copy of the specified repository request.
*
* @param repositoryRequest The repository request to copy from, must not be {@code null}.
*/
public DefaultRepositoryRequest( RepositoryRequest repositoryRequest )
{
setLocalRepository( repositoryRequest.getLocalRepository() );
setRemoteRepositories( repositoryRequest.getRemoteRepositories() );
setOffline( repositoryRequest.isOffline() );
setCache( repositoryRequest.getCache() );
}
public boolean isOffline()
{
return offline;

View File

@ -19,11 +19,11 @@ package org.apache.maven.repository.legacy.metadata;
* under the License.
*/
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
import org.apache.maven.artifact.repository.RepositoryCache;
import org.apache.maven.artifact.repository.RepositoryRequest;
@ -38,27 +38,18 @@ public class DefaultMetadataResolutionRequest
private Artifact artifact;
private ArtifactRepository localRepository;
private List<ArtifactRepository> remoteRepositories;
private RepositoryCache cache;
private boolean resolveManagedVersions;
private boolean offline;
private RepositoryRequest repositoryRequest;
public DefaultMetadataResolutionRequest()
{
// does nothing
repositoryRequest = new DefaultRepositoryRequest();
}
public DefaultMetadataResolutionRequest( RepositoryRequest request )
public DefaultMetadataResolutionRequest( RepositoryRequest repositoryRequest )
{
setLocalRepository( request.getLocalRepository() );
setRemoteRepositories( request.getRemoteRepositories() );
setCache( request.getCache() );
setOffline( request.isOffline() );
this.repositoryRequest = new DefaultRepositoryRequest( repositoryRequest );
}
public Artifact getArtifact()
@ -75,29 +66,24 @@ public class DefaultMetadataResolutionRequest
public ArtifactRepository getLocalRepository()
{
return localRepository;
return repositoryRequest.getLocalRepository();
}
public DefaultMetadataResolutionRequest setLocalRepository( ArtifactRepository localRepository )
{
this.localRepository = localRepository;
repositoryRequest.setLocalRepository( localRepository );
return this;
}
public List<ArtifactRepository> getRemoteRepositories()
{
if ( remoteRepositories == null )
{
remoteRepositories = new ArrayList<ArtifactRepository>();
}
return remoteRepositories;
return repositoryRequest.getRemoteRepositories();
}
public DefaultMetadataResolutionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
{
this.remoteRepositories = remoteRepositories;
repositoryRequest.setRemoteRepositories( remoteRepositories );
return this;
}
@ -116,24 +102,24 @@ public class DefaultMetadataResolutionRequest
public RepositoryCache getCache()
{
return cache;
return repositoryRequest.getCache();
}
public DefaultMetadataResolutionRequest setCache( RepositoryCache cache )
{
this.cache = cache;
repositoryRequest.setCache( cache );
return this;
}
public boolean isOffline()
{
return offline;
return repositoryRequest.isOffline();
}
public DefaultMetadataResolutionRequest setOffline( boolean offline )
{
this.offline = offline;
repositoryRequest.setOffline( offline );
return this;
}