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

com.app.common.validator.ValidatorFactory Maven / Gradle / Ivy

The newest version!
package com.app.common.validator;

import java.util.concurrent.ConcurrentHashMap;
/**
 * 参数验证工厂类
 * @author Administrator
 *
 */
public class ValidatorFactory {
	private static final ConcurrentHashMap hmValidator = new ConcurrentHashMap();
	static {
	 
		hmValidator.put(ValidatorType.numberLimit.toString(), new NumberLimitValidator());
		hmValidator.put(ValidatorType.valuesLimit.toString(), new ValuesLimitValidator());
	 
	}

	public static IValidator getValidator(String name) {
		return hmValidator.get(name);
	}
	/**
	 * 添加参数验证器
	 * @param name
	 * @param validator
	 */
	public static void addValidator(String name, IValidator validator) {
		hmValidator.putIfAbsent(name, validator);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy