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.nio.file.StandardOpenOption;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -42,7 +41,7 @@ import com.inteligr8.nio.DelimitedReadableByteChannel;
|
|||||||
public abstract class AbstractReplaceMojo extends AbstractRegexMojo {
|
public abstract class AbstractReplaceMojo extends AbstractRegexMojo {
|
||||||
|
|
||||||
@Parameter( property = "regexes", required = true )
|
@Parameter( property = "regexes", required = true )
|
||||||
protected List<Regex> regexes;
|
protected Regex[] regexes;
|
||||||
|
|
||||||
// Pattern does not implement hashCode, so not using a Map
|
// Pattern does not implement hashCode, so not using a Map
|
||||||
private List<Triple<Pattern, String, Pattern>> compiledRegexes;
|
private List<Triple<Pattern, String, Pattern>> compiledRegexes;
|
||||||
@ -256,7 +255,7 @@ public abstract class AbstractReplaceMojo extends AbstractRegexMojo {
|
|||||||
protected void validateParamsPreNormalization() throws MojoFailureException {
|
protected void validateParamsPreNormalization() throws MojoFailureException {
|
||||||
super.validateParamsPreNormalization();
|
super.validateParamsPreNormalization();
|
||||||
|
|
||||||
if (this.regexes == null)
|
if (this.regexes == null || this.regexes.length == 0)
|
||||||
throw new MojoFailureException("A 'regexes' element is required");
|
throw new MojoFailureException("A 'regexes' element is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,22 +263,15 @@ public abstract class AbstractReplaceMojo extends AbstractRegexMojo {
|
|||||||
protected void normalizeParameters() throws MojoFailureException {
|
protected void normalizeParameters() throws MojoFailureException {
|
||||||
super.normalizeParameters();
|
super.normalizeParameters();
|
||||||
|
|
||||||
ListIterator<Regex> r = this.regexes.listIterator();
|
for (Regex regex : this.regexes)
|
||||||
while (r.hasNext()) {
|
regex.normalize();
|
||||||
Regex regex = r.next();
|
|
||||||
if (regex == null) {
|
|
||||||
r.remove();
|
|
||||||
} else {
|
|
||||||
regex.normalize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void validateParamsPostNormalization() throws MojoFailureException {
|
protected void validateParamsPostNormalization() throws MojoFailureException {
|
||||||
super.validateParamsPostNormalization();
|
super.validateParamsPostNormalization();
|
||||||
|
|
||||||
if (this.regexes.isEmpty())
|
if (this.regexes == null || this.regexes.length == 0)
|
||||||
throw new MojoFailureException("At least one 'regexes' element is required");
|
throw new MojoFailureException("At least one 'regexes' element is required");
|
||||||
|
|
||||||
this.compiledRegexes = new LinkedList<>();
|
this.compiledRegexes = new LinkedList<>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user