diff --git a/src/main/java/com/inteligr8/maven/regex/AbstractReplaceMojo.java b/src/main/java/com/inteligr8/maven/regex/AbstractReplaceMojo.java index 4dbd9e2..0527dd3 100644 --- a/src/main/java/com/inteligr8/maven/regex/AbstractReplaceMojo.java +++ b/src/main/java/com/inteligr8/maven/regex/AbstractReplaceMojo.java @@ -24,7 +24,6 @@ import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; import java.util.LinkedList; import java.util.List; -import java.util.ListIterator; import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -42,7 +41,7 @@ import com.inteligr8.nio.DelimitedReadableByteChannel; public abstract class AbstractReplaceMojo extends AbstractRegexMojo { @Parameter( property = "regexes", required = true ) - protected List regexes; + protected Regex[] regexes; // Pattern does not implement hashCode, so not using a Map private List> compiledRegexes; @@ -256,7 +255,7 @@ public abstract class AbstractReplaceMojo extends AbstractRegexMojo { protected void validateParamsPreNormalization() throws MojoFailureException { super.validateParamsPreNormalization(); - if (this.regexes == null) + if (this.regexes == null || this.regexes.length == 0) throw new MojoFailureException("A 'regexes' element is required"); } @@ -264,22 +263,15 @@ public abstract class AbstractReplaceMojo extends AbstractRegexMojo { protected void normalizeParameters() throws MojoFailureException { super.normalizeParameters(); - ListIterator r = this.regexes.listIterator(); - while (r.hasNext()) { - Regex regex = r.next(); - if (regex == null) { - r.remove(); - } else { - regex.normalize(); - } - } + for (Regex regex : this.regexes) + regex.normalize(); } @Override protected void validateParamsPostNormalization() throws MojoFailureException { super.validateParamsPostNormalization(); - if (this.regexes.isEmpty()) + if (this.regexes == null || this.regexes.length == 0) throw new MojoFailureException("At least one 'regexes' element is required"); this.compiledRegexes = new LinkedList<>();