array to list
This commit is contained in:
parent
3499a717e2
commit
eef0b3c2bf
@ -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<Regex> regexes;
|
||||
protected Regex[] regexes;
|
||||
|
||||
// Pattern does not implement hashCode, so not using a Map
|
||||
private List<Triple<Pattern, String, Pattern>> 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<Regex> 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<>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user