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

com.jchanghong.cron.pattern.matcher.BoolArrayValueMatcher Maven / Gradle / Ivy

The newest version!
package com.jchanghong.cron.pattern.matcher;

import java.util.Collections;
import java.util.List;

import com.jchanghong.core.util.StrUtil;

/**
 * 将表达式中的数字值列表转换为Boolean数组,匹配时匹配相应数组位
 * @author Looly
 *
 */
public class BoolArrayValueMatcher implements ValueMatcher{
	
	private final boolean[] bValues;
	
	public BoolArrayValueMatcher(List intValueList) {
		bValues = new boolean[Collections.max(intValueList) + 1];
		for (Integer value : intValueList) {
			bValues[value] = true;
		}
	}

	@Override
	public boolean match(Integer value) {
		if(null == value || value >= bValues.length){
			return false;
		}
		return bValues[value];
	}
	
	@Override
	public String toString() {
		return StrUtil.format("Matcher:{}", (Object)this.bValues);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy