Author: bentmann
Date: Sat Jun 20 19:39:56 2009
New Revision: 786892
URL: http://svn.apache.org/viewvc?rev=786892&view=rev
Log:
o Fixed buggy anti-pattern
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=786892&r1=786891&r2=786892&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
Sat Jun 20 19:39:56 2009
@@ -217,28 +217,52 @@
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 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 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 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 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 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 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 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;
}
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java?rev=786892&r1=786891&r2=786892&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
Sat Jun 20 19:39:56 2009
@@ -38,7 +38,7 @@
private List<ArtifactRepository> pluginArtifactRepositories;
private List<ModelEventListener> listeners;
-
+
private MavenProject topProject;
private boolean lenientValidation;
@@ -68,13 +68,13 @@
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 @@
{
return localRepository;
}
-
+
public List<ArtifactRepository> getRemoteRepositories()
{
return remoteRepositories;
@@ -94,11 +94,13 @@
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 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 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 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 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()
Modified:
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java?rev=786892&r1=786891&r2=786892&view=diff
==============================================================================
---
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java
(original)
+++
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java
Sat Jun 20 19:39:56 2009
@@ -51,14 +51,6 @@
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 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 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 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 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;
}
Modified:
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java?rev=786892&r1=786891&r2=786892&view=diff
==============================================================================
---
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java
(original)
+++
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java
Sat Jun 20 19:39:56 2009
@@ -135,11 +135,13 @@
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;
Modified:
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java?rev=786892&r1=786891&r2=786892&view=diff
==============================================================================
---
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
(original)
+++
maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
Sat Jun 20 19:39:56 2009
@@ -38,24 +38,25 @@
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 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 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;
}