// Path: src/main/java/cz/sigler/android/aavalidation/validator/MinValidator.java
// public class MinValidator implements IConstraintValidator<Number, Min> {
// 
// 	private Comparable param;
// 
// 	private Boolean equal;
// 	
// 	/**
// 	 * {@inheritDoc }
// 	 */
// 	@Override
// 	public void initialize(final Min annotation) {
// 
// 		if (annotation.valueStr().length() > 0) { //string representation is set
// 			param = Double.parseDouble(annotation.valueStr());
// 		} else {
// 			param = annotation.value();
// 		}
// 
// 		equal = annotation.equal();
// 	}
// 
// 	/**
// 	 * {@inheritDoc }
// 	 */
// 	@Override
// 	public boolean isValid(IValueDescriptor<Number> value) {
// 		if (value.getValue() == null) {
// 			return true;
// 		}
// 
// 		//convert the compared value to the right type
// 		Number valueToCompare;
// 		if (param instanceof Double) {
// 			valueToCompare = value.getValue().doubleValue();
// 		} else {
// 			valueToCompare = value.getValue().longValue();
// 		}
// 
// 		int	comparisonResult = param.compareTo(valueToCompare);
// 
// 		return (comparisonResult < 0) || (equal && (comparisonResult == 0));
// 	}
// 
// }


import cz.sigler.android.aavalidation.api.rule.Constraint;
import cz.sigler.android.aavalidation.validator.MinValidator;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/*
 * Copyright (C) 2013 Vojtech Sigler.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cz.sigler.android.aavalidation.rule;


/**
 * Rule defining that the target is greater (or equal) to specified value.
 *
 * Parameters can be set as a long or a string representation of a
 * decimal value.
 *
 * When the long param is used, validation will compare against a long value.
 * Otherwise a decimal (Double) value is used for comparison.
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(MinValidator.class)
public @interface Min {
	/**
	 * @return Error message text.
	 */
	String message();

	/**
	 * @return Error message resource id.
	 */
	int messageResId() default 0;

	/**
	 * @return Lower boundary of the validated value.
	 */
// Path: src/main/java/cz/sigler/android/aavalidation/validator/MinValidator.java
// public class MinValidator implements IConstraintValidator<Number, Min> {
// 
// 	private Comparable param;
// 
// 	private Boolean equal;
// 	
// 	/**
// 	 * {@inheritDoc }
// 	 */
// 	@Override
// 	public void initialize(final Min annotation) {
// 
// 		if (annotation.valueStr().length() > 0) { //string representation is set
// 			param = Double.parseDouble(annotation.valueStr());
// 		} else {
// 			param = annotation.value();
// 		}
// 
// 		equal = annotation.equal();
// 	}
// 
// 	/**
// 	 * {@inheritDoc }
// 	 */
// 	@Override
// 	public boolean isValid(IValueDescriptor<Number> value) {
// 		if (value.getValue() == null) {
// 			return true;
// 		}
// 
// 		//convert the compared value to the right type
// 		Number valueToCompare;
// 		if (param instanceof Double) {
// 			valueToCompare = value.getValue().doubleValue();
// 		} else {
// 			valueToCompare = value.getValue().longValue();
// 		}
// 
// 		int	comparisonResult = param.compareTo(valueToCompare);
// 
// 		return (comparisonResult < 0) || (equal && (comparisonResult == 0));
// 	}
// 
// }


// Path: src/main/java/cz/sigler/android/aavalidation/rule/Min.java
import cz.sigler.android.aavalidation.api.rule.Constraint;
import cz.sigler.android.aavalidation.validator.MinValidator;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/*
 * Copyright (C) 2013 Vojtech Sigler.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cz.sigler.android.aavalidation.rule;


/**
 * Rule defining that the target is greater (or equal) to specified value.
 *
 * Parameters can be set as a long or a string representation of a
 * decimal value.
 *
 * When the long param is used, validation will compare against a long value.
 * Otherwise a decimal (Double) value is used for comparison.
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(MinValidator.class)
public @interface Min {
	/**
	 * @return Error message text.
	 */
	String message();

	/**
	 * @return Error message resource id.
	 */
	int messageResId() default 0;

	/**
	 * @return Lower boundary of the validated value.
	 */
	long value() default Long.MAX_VALUE;