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

com.github.ldeitos.validators.MinDecimalValidatorImpl Maven / Gradle / Ivy

package com.github.ldeitos.validators;

import java.math.BigDecimal;

import com.github.ldeitos.constraint.DecimalMin;

public class MinDecimalValidatorImpl extends BigDecimalComparativeValidator 
	implements MinDecimalValidator {
	private BigDecimal minValue;
	
	private boolean inclusive;

	public void initialize(DecimalMin constraintAnnotation) {
		minValue = new BigDecimal(constraintAnnotation.value());
		inclusive = constraintAnnotation.inclusive();
	}

	@Override
	protected boolean compareValid(BigDecimal n) {
		int comparassion = minValue.compareTo(n);
		return inclusive ? comparassion <= 0 : comparassion < 0;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy