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

com.xiaoleilu.hutool.cron.pattern.matcher.BoolArrayValueMatcher Maven / Gradle / Ivy

package com.xiaoleilu.hutool.cron.pattern.matcher;

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

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 将表达式中的数字值列表转换为Boolean数组,匹配时匹配相应数组位
 * @author Looly
 *
 */
public class BoolArrayValueMatcher implements ValueMatcher{
	
	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