Commit eef0b3c2 authored by Brian Long's avatar Brian Long
Browse files

array to list

parent 3499a717
Loading
Loading
Loading
Loading
+4 −12
Changes for src/main/java/com/inteligr8/maven/regex/AbstractReplaceMojo.java: 4 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -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 {
    	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<>();