[MNG-7051] Return unmodifiable profile lists

This helps deprecation and keeps the code consistent.

Closes #452.
This commit is contained in:
Maarten Mulders 2021-02-12 17:06:47 +01:00
parent 9643ac630c
commit ad24f599ce
2 changed files with 11 additions and 10 deletions

View File

@ -278,51 +278,51 @@ public interface MavenExecutionRequest
MavenExecutionRequest setProfiles( List<Profile> profiles ); MavenExecutionRequest setProfiles( List<Profile> profiles );
/** /**
* @deprecated Use {@link #getProfileActivation()}. * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/ */
@Deprecated @Deprecated
MavenExecutionRequest addActiveProfile( String profile ); MavenExecutionRequest addActiveProfile( String profile );
/** /**
* @deprecated Use {@link #getProfileActivation()}. * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/ */
@Deprecated @Deprecated
MavenExecutionRequest addActiveProfiles( List<String> profiles ); MavenExecutionRequest addActiveProfiles( List<String> profiles );
/** /**
* @deprecated Use {@link #getProfileActivation()}. * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/ */
@Deprecated @Deprecated
MavenExecutionRequest setActiveProfiles( List<String> profiles ); MavenExecutionRequest setActiveProfiles( List<String> profiles );
/** /**
* @return The list of profiles that the user wants to activate. * @return The list of profiles that the user wants to activate.
* @deprecated Use {@link #getProfileActivation()}. * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/ */
@Deprecated @Deprecated
List<String> getActiveProfiles(); List<String> getActiveProfiles();
/** /**
* @deprecated Use {@link #getProfileActivation()}. * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/ */
@Deprecated @Deprecated
MavenExecutionRequest addInactiveProfile( String profile ); MavenExecutionRequest addInactiveProfile( String profile );
/** /**
* @deprecated Use {@link #getProfileActivation()}. * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/ */
@Deprecated @Deprecated
MavenExecutionRequest addInactiveProfiles( List<String> profiles ); MavenExecutionRequest addInactiveProfiles( List<String> profiles );
/** /**
* @deprecated Use {@link #getProfileActivation()}. * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/ */
@Deprecated @Deprecated
MavenExecutionRequest setInactiveProfiles( List<String> profiles ); MavenExecutionRequest setInactiveProfiles( List<String> profiles );
/** /**
* @return The list of profiles that the user wants to de-activate. * @return The list of profiles that the user wants to de-activate.
* @deprecated Use {@link #getProfileActivation()}. * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
*/ */
@Deprecated @Deprecated
List<String> getInactiveProfiles(); List<String> getInactiveProfiles();

View File

@ -20,6 +20,7 @@ package org.apache.maven.execution;
*/ */
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -74,7 +75,7 @@ public class ProfileActivation
@Deprecated @Deprecated
public List<String> getActiveProfiles() public List<String> getActiveProfiles()
{ {
return new ArrayList<>( getProfileIds( pa -> pa.active ) ); return Collections.unmodifiableList( new ArrayList<>( getProfileIds( pa -> pa.active ) ) );
} }
/** /**
@ -84,7 +85,7 @@ public class ProfileActivation
@Deprecated @Deprecated
public List<String> getInactiveProfiles() public List<String> getInactiveProfiles()
{ {
return new ArrayList<>( getProfileIds( pa -> !pa.active ) ); return Collections.unmodifiableList( new ArrayList<>( getProfileIds( pa -> !pa.active ) ) );
} }
/** /**