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; 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() public boolean isOffline()
{ {
return offline; return offline;

View File

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