All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.portalkit.engines.mailhunter.matcher.GenericAndMatcher Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package net.anotheria.portalkit.engines.mailhunter.matcher;

import java.util.ArrayList;
import java.util.List;

public class GenericAndMatcher extends AbstractMatcher{
	
	private ArrayList firstValues;
	private ArrayList secondValues;

	public GenericAndMatcher(List aFirstValues, List aSecondValues, double aReduction){
		super(aReduction);
		
		firstValues = new ArrayList();
		if (aFirstValues!=null)
			firstValues.addAll(aFirstValues);
		
		secondValues = new ArrayList();
		if (aSecondValues!=null)
			secondValues.addAll(aSecondValues);
		
	}
	
	public void addFirstValue(String aValue){
		firstValues.add(aValue);
	}
	
	public void addSecondValue(String aValue){
		secondValues.add(aValue);
	}

	public boolean doesMatch(String expression) {
		for (String val1 : firstValues) {
			int index1 = expression.indexOf(val1);
			if (index1 != -1) {
				for (String val2 : secondValues) {
					int index2 = expression.indexOf(val2);
					if (index2 > index1)
						return true;
				}
			}
		}
		return false;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy