top.cutexingluo.tools.common.valid.num.floatstatus.FloatStatusValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xingtools-pkg-jdk8 Show documentation
Show all versions of xingtools-pkg-jdk8 Show documentation
xingtools 依赖core包,jdk 分类包,对不同的jdk版本提供兼容性
The newest version!
package top.cutexingluo.tools.common.valid.num.floatstatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import top.cutexingluo.tools.common.valid.StatusValidator;
import top.cutexingluo.tools.utils.se.map.XTSetUtil;
import javax.validation.ConstraintValidatorContext;
/**
* FloatStatus 检验器
*
* @author XingTian
* @version 1.0.0
* @date 2023/12/8 18:47
* @since 1.1.2
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class FloatStatusValidator extends StatusValidator {
protected FloatStatusConfig statusConfig;
protected FloatValidator validator;
@Override
public void initialize(FloatStatus constraintAnnotation) {
statusConfig = new FloatStatusConfig(
constraintAnnotation.notNull(),
XTSetUtil.toSet(constraintAnnotation.matchNum()),
constraintAnnotation.limit(),
constraintAnnotation.eps(),
constraintAnnotation.min(),
constraintAnnotation.max(),
FloatRangeData.parse(constraintAnnotation.range())
);
validator = new FloatValidator(statusConfig);
}
@Override
public boolean isValid(Float value, ConstraintValidatorContext constraintValidatorContext) {
return validator.isValid(value);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy