o Fixed buggy anti-pattern

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@786892 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-06-20 19:39:56 +00:00
parent 12fbba751a
commit 2260cb2f58
5 changed files with 204 additions and 79 deletions

View File

@ -217,28 +217,52 @@ public class DefaultMavenExecutionRequest
public void setActiveProfiles( List<String> activeProfiles )
{
getActiveProfiles().clear();
getActiveProfiles().addAll( activeProfiles );
if ( activeProfiles != null )
{
this.activeProfiles = new ArrayList<String>( activeProfiles );
}
else
{
this.activeProfiles = null;
}
}
public void setInactiveProfiles( List<String> inactiveProfiles )
{
getInactiveProfiles().clear();
getInactiveProfiles().addAll( inactiveProfiles );
if ( inactiveProfiles != null )
{
this.inactiveProfiles = new ArrayList<String>( inactiveProfiles );
}
else
{
this.inactiveProfiles = null;
}
}
public MavenExecutionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
{
getRemoteRepositories().clear();
getRemoteRepositories().addAll( remoteRepositories );
if ( remoteRepositories != null )
{
this.remoteRepositories = new ArrayList<ArtifactRepository>( remoteRepositories );
}
else
{
this.remoteRepositories = null;
}
return this;
}
public MavenExecutionRequest setPluginArtifactRepositories( List<ArtifactRepository> pluginArtifactRepositories )
{
getPluginArtifactRepositories().clear();
getPluginArtifactRepositories().addAll( pluginArtifactRepositories );
if ( pluginArtifactRepositories != null )
{
this.pluginArtifactRepositories = new ArrayList<ArtifactRepository>( pluginArtifactRepositories );
}
else
{
this.pluginArtifactRepositories = null;
}
return this;
}
@ -328,8 +352,14 @@ public class DefaultMavenExecutionRequest
public MavenExecutionRequest setGoals( List<String> goals )
{
getGoals().clear();
getGoals().addAll( goals );
if ( goals != null )
{
this.goals = new ArrayList<String>( goals );
}
else
{
this.goals = null;
}
return this;
}
@ -357,8 +387,15 @@ public class DefaultMavenExecutionRequest
public MavenExecutionRequest setProperties( Properties properties )
{
getProperties().clear();
getProperties().putAll( properties );
if ( properties != null )
{
this.properties = new Properties();
this.properties.putAll( properties );
}
else
{
this.properties = null;
}
return this;
}
@ -511,8 +548,14 @@ public class DefaultMavenExecutionRequest
public MavenExecutionRequest setProxies( List proxies )
{
getProxies().clear();
getProxies().addAll( proxies );
if ( proxies != null )
{
this.proxies = new ArrayList( proxies );
}
else
{
this.proxies = null;
}
return this;
}
@ -528,8 +571,14 @@ public class DefaultMavenExecutionRequest
public MavenExecutionRequest setServers( List servers )
{
getServers().clear();
getServers().addAll( servers );
if ( servers != null )
{
this.servers = new ArrayList( servers );
}
else
{
this.servers = null;
}
return this;
}
@ -545,8 +594,14 @@ public class DefaultMavenExecutionRequest
public MavenExecutionRequest setMirrors( List mirrors )
{
getMirrors().clear();
getMirrors().addAll( mirrors );
if ( mirrors != null )
{
this.mirrors = new ArrayList( mirrors );
}
else
{
this.mirrors = null;
}
return this;
}
@ -562,8 +617,14 @@ public class DefaultMavenExecutionRequest
public MavenExecutionRequest setProfiles( List<Profile> profiles )
{
getProfiles().clear();
getProfiles().addAll( profiles );
if ( profiles != null )
{
this.profiles = new ArrayList<Profile>( profiles );
}
else
{
this.profiles = null;
}
return this;
}
@ -580,8 +641,14 @@ public class DefaultMavenExecutionRequest
public MavenExecutionRequest setPluginGroups( List<String> pluginGroups )
{
getPluginGroups().clear();
getPluginGroups().addAll( pluginGroups );
if ( pluginGroups != null )
{
this.pluginGroups = new ArrayList<String>( pluginGroups );
}
else
{
this.pluginGroups = null;
}
return this;
}

View File

@ -38,7 +38,7 @@ public class DefaultProjectBuildingRequest
private List<ArtifactRepository> pluginArtifactRepositories;
private List<ModelEventListener> listeners;
private MavenProject topProject;
private boolean lenientValidation;
@ -68,13 +68,13 @@ public class DefaultProjectBuildingRequest
public MavenProject getTopLevelProjectFromReactor()
{
return topProject;
return topProject;
}
public void setTopLevelProjectForReactor(MavenProject mavenProject)
public void setTopLevelProjectForReactor( MavenProject mavenProject )
{
this.topProject = mavenProject;
}
this.topProject = mavenProject;
}
public ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository )
{
@ -86,7 +86,7 @@ public class DefaultProjectBuildingRequest
{
return localRepository;
}
public List<ArtifactRepository> getRemoteRepositories()
{
return remoteRepositories;
@ -94,11 +94,13 @@ public class DefaultProjectBuildingRequest
public ProjectBuildingRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
{
this.remoteRepositories.clear();
if ( remoteRepositories != null )
{
this.remoteRepositories.addAll( remoteRepositories );
this.remoteRepositories = new ArrayList<ArtifactRepository>( remoteRepositories );
}
else
{
this.remoteRepositories.clear();
}
return this;
@ -111,16 +113,18 @@ public class DefaultProjectBuildingRequest
public ProjectBuildingRequest setPluginArtifactRepositories( List<ArtifactRepository> pluginArtifactRepositories )
{
this.pluginArtifactRepositories.clear();
if ( pluginArtifactRepositories != null )
{
this.pluginArtifactRepositories.addAll( pluginArtifactRepositories );
this.pluginArtifactRepositories = new ArrayList<ArtifactRepository>( pluginArtifactRepositories );
}
else
{
this.pluginArtifactRepositories.clear();
}
return this;
}
public Properties getExecutionProperties()
{
return executionProperties;
@ -128,12 +132,15 @@ public class DefaultProjectBuildingRequest
public ProjectBuildingRequest setExecutionProperties( Properties executionProperties )
{
this.executionProperties.clear();
if ( executionProperties != null )
{
this.executionProperties = new Properties();
this.executionProperties.putAll( executionProperties );
}
else
{
this.executionProperties.clear();
}
return this;
}
@ -178,11 +185,13 @@ public class DefaultProjectBuildingRequest
public void setActiveProfileIds( List<String> activeProfileIds )
{
this.activeProfileIds.clear();
if ( activeProfileIds != null )
{
this.activeProfileIds.addAll( activeProfileIds );
this.activeProfileIds = new ArrayList<String>( activeProfileIds );
}
else
{
this.activeProfileIds.clear();
}
}
@ -193,27 +202,31 @@ public class DefaultProjectBuildingRequest
public void setInactiveProfileIds( List<String> inactiveProfileIds )
{
this.inactiveProfileIds.clear();
if ( inactiveProfileIds != null )
{
this.inactiveProfileIds.addAll( inactiveProfileIds );
this.inactiveProfileIds = new ArrayList<String>( inactiveProfileIds );
}
else
{
this.inactiveProfileIds.clear();
}
}
public void setProfiles( List<Profile> profiles )
{
this.profiles.clear();
if ( profiles != null )
{
this.profiles.addAll( profiles );
this.profiles = new ArrayList<Profile>( profiles );
}
else
{
this.profiles.clear();
}
}
public void addProfile( Profile profile )
{
profiles.add(profile);
profiles.add( profile );
}
public List<Profile> getProfiles()

View File

@ -51,14 +51,6 @@ public class DefaultModelBuildingRequest
private ModelResolver modelResolver;
public DefaultModelBuildingRequest()
{
profiles = new ArrayList<Profile>();
activeProfileIds = new ArrayList<String>();
inactiveProfileIds = new ArrayList<String>();
executionProperties = new Properties();
}
public boolean istLenientValidation()
{
return lenientValidation;
@ -85,15 +77,23 @@ public class DefaultModelBuildingRequest
public List<Profile> getProfiles()
{
if ( profiles == null )
{
profiles = new ArrayList<Profile>();
}
return profiles;
}
public DefaultModelBuildingRequest setProfiles( List<Profile> profiles )
{
this.profiles.clear();
if ( profiles != null )
{
this.profiles.addAll( profiles );
this.profiles = new ArrayList<Profile>( profiles );
}
else
{
this.profiles = null;
}
return this;
@ -101,15 +101,23 @@ public class DefaultModelBuildingRequest
public List<String> getActiveProfileIds()
{
if ( activeProfileIds == null )
{
activeProfileIds = new ArrayList<String>();
}
return activeProfileIds;
}
public DefaultModelBuildingRequest setActiveProfileIds( List<String> activeProfileIds )
{
this.activeProfileIds.clear();
if ( activeProfileIds != null )
{
this.activeProfileIds.addAll( activeProfileIds );
this.activeProfileIds = new ArrayList<String>( activeProfileIds );
}
else
{
this.activeProfileIds = null;
}
return this;
@ -117,15 +125,23 @@ public class DefaultModelBuildingRequest
public List<String> getInactiveProfileIds()
{
if ( inactiveProfileIds == null )
{
inactiveProfileIds = new ArrayList<String>();
}
return inactiveProfileIds;
}
public DefaultModelBuildingRequest setInactiveProfileIds( List<String> inactiveProfileIds )
{
this.inactiveProfileIds.clear();
if ( inactiveProfileIds != null )
{
this.inactiveProfileIds.addAll( inactiveProfileIds );
this.inactiveProfileIds = new ArrayList<String>( inactiveProfileIds );
}
else
{
this.inactiveProfileIds = null;
}
return this;
@ -133,16 +149,25 @@ public class DefaultModelBuildingRequest
public Properties getExecutionProperties()
{
if ( executionProperties == null )
{
executionProperties = new Properties();
}
return executionProperties;
}
public DefaultModelBuildingRequest setExecutionProperties( Properties executionProperties )
{
this.executionProperties.clear();
if ( executionProperties != null )
{
this.executionProperties = new Properties();
this.executionProperties.putAll( executionProperties );
}
else
{
this.executionProperties = null;
}
return this;
}

View File

@ -135,11 +135,13 @@ class DefaultModelBuildingResult
public DefaultModelBuildingResult setActiveExternalProfiles( List<Profile> activeProfiles )
{
this.activeExternalProfiles.clear();
if ( activeProfiles != null )
{
this.activeExternalProfiles.addAll( activeProfiles );
this.activeExternalProfiles = new ArrayList<Profile>( activeProfiles );
}
else
{
this.activeExternalProfiles.clear();
}
return this;

View File

@ -38,24 +38,25 @@ public class DefaultProfileActivationContext
private Properties executionProperties;
public DefaultProfileActivationContext()
{
activeProfileIds = new ArrayList<String>();
inactiveProfileIds = new ArrayList<String>();
executionProperties = new Properties();
}
public List<String> getActiveProfileIds()
{
if ( activeProfileIds == null )
{
activeProfileIds = new ArrayList<String>();
}
return activeProfileIds;
}
public DefaultProfileActivationContext setActiveProfileIds( List<String> activeProfileIds )
{
this.activeProfileIds.clear();
if ( activeProfileIds != null )
{
this.activeProfileIds.addAll( activeProfileIds );
this.activeProfileIds = new ArrayList<String>( activeProfileIds );
}
else
{
this.activeProfileIds = null;
}
return this;
@ -63,15 +64,23 @@ public class DefaultProfileActivationContext
public List<String> getInactiveProfileIds()
{
if ( inactiveProfileIds == null )
{
inactiveProfileIds = new ArrayList<String>();
}
return inactiveProfileIds;
}
public DefaultProfileActivationContext setInactiveProfileIds( List<String> inactiveProfileIds )
{
this.inactiveProfileIds.clear();
if ( inactiveProfileIds != null )
{
this.inactiveProfileIds.addAll( inactiveProfileIds );
this.inactiveProfileIds = new ArrayList<String>( inactiveProfileIds );
}
else
{
this.inactiveProfileIds = null;
}
return this;
@ -79,16 +88,25 @@ public class DefaultProfileActivationContext
public Properties getExecutionProperties()
{
if ( executionProperties == null )
{
executionProperties = new Properties();
}
return executionProperties;
}
public DefaultProfileActivationContext setExecutionProperties( Properties executionProperties )
{
this.executionProperties.clear();
if ( executionProperties != null )
{
this.executionProperties = new Properties();
this.executionProperties.putAll( executionProperties );
}
else
{
this.executionProperties = null;
}
return this;
}