package com.ssm.util.sms.excel.validation.rule;

import com.ssm.util.sms.excel.validation.Validation;

import com.ssm.util.sms.excel.validation.base.ValidationMap;

public class ValidationRule {
	private Validation validation;
	private Integer[] validateIndex;

	public ValidationRule(Validation validation, Integer[] validateIndex) {
		this.validation = validation;
		this.validateIndex = validateIndex;
	}

	public ValidationRule(Object validateValue, Integer[] validateIndex)
			throws Exception {
		this.validateIndex = validateIndex;
		if ((validateValue instanceof Validation)) {
			this.validation = ((Validation) validateValue);
		} else if ((validateValue instanceof String)) {
			Class getClass = (Class) ValidationMap.validateMap
					.get(validateValue);
			this.validation = ((Validation) getClass.newInstance());
		} else {
			throw new ClassCastException();
		}
	}

	public Validation getValidation() {
		return this.validation;
	}

	public Integer[] getValidateIndex() {
		return this.validateIndex;
	}
}
