mirror of https://github.com/apache/maven.git
Proposal to change abstract provider
Changes: * validate input * do not modify loop invariant within loop body
This commit is contained in:
parent
a53083db6c
commit
7180d68a18
|
@ -29,6 +29,8 @@ import org.apache.maven.lifecycle.mapping.Lifecycle;
|
||||||
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
|
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
|
||||||
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
|
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base lifecycle mapping provider, ie per-packaging plugin bindings for {@code default} lifecycle.
|
* Base lifecycle mapping provider, ie per-packaging plugin bindings for {@code default} lifecycle.
|
||||||
*/
|
*/
|
||||||
|
@ -39,11 +41,17 @@ public abstract class AbstractLifecycleMappingProvider
|
||||||
|
|
||||||
protected AbstractLifecycleMappingProvider( String[] pluginBindings )
|
protected AbstractLifecycleMappingProvider( String[] pluginBindings )
|
||||||
{
|
{
|
||||||
HashMap<String, LifecyclePhase> lifecyclePhases = new HashMap<>();
|
requireNonNull( pluginBindings );
|
||||||
int len = pluginBindings.length;
|
final int len = pluginBindings.length;
|
||||||
for ( int i = 0; i < len; i++ )
|
if ( len < 1 || len % 2 != 0 )
|
||||||
{
|
{
|
||||||
lifecyclePhases.put( pluginBindings[i++], new LifecyclePhase( pluginBindings[i] ) );
|
throw new IllegalArgumentException( "Plugin bindings must have more than 0, even count of elements" );
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, LifecyclePhase> lifecyclePhases = new HashMap<>( len / 2 );
|
||||||
|
for ( int i = 0; i < len; i = i + 2 )
|
||||||
|
{
|
||||||
|
lifecyclePhases.put( pluginBindings[i], new LifecyclePhase( pluginBindings[i + 1] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Lifecycle lifecycle = new Lifecycle();
|
Lifecycle lifecycle = new Lifecycle();
|
||||||
|
|
Loading…
Reference in New Issue