Java Code Examples for javax.validation.constraints.DecimalMin#value()

The following examples show how to use javax.validation.constraints.DecimalMin#value() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaxValidationModule.java    From jsonschema-generator with Apache License 2.0 6 votes vote down vote up
/**
 * Determine a number type's minimum (inclusive) value.
 *
 * @param member the field or method to check
 * @return specified inclusive minimum value (or null)
 * @see Min
 * @see DecimalMin
 * @see PositiveOrZero
 */
protected BigDecimal resolveNumberInclusiveMinimum(MemberScope<?, ?> member) {
    Min minAnnotation = this.getAnnotationFromFieldOrGetter(member, Min.class, Min::groups);
    if (minAnnotation != null) {
        return new BigDecimal(minAnnotation.value());
    }
    DecimalMin decimalMinAnnotation = this.getAnnotationFromFieldOrGetter(member, DecimalMin.class, DecimalMin::groups);
    if (decimalMinAnnotation != null && decimalMinAnnotation.inclusive()) {
        return new BigDecimal(decimalMinAnnotation.value());
    }
    PositiveOrZero positiveAnnotation = this.getAnnotationFromFieldOrGetter(member, PositiveOrZero.class, PositiveOrZero::groups);
    if (positiveAnnotation != null) {
        return BigDecimal.ZERO;
    }
    return null;
}
 
Example 2
Source File: DecimalMinPostProcessor.java    From RestDoc with Apache License 2.0 5 votes vote down vote up
@Override
public PropertyModel postProcessInternal(PropertyModel propertyModel) {
    DecimalMin minAnno = propertyModel.getPropertyItem().getAnnotation(DecimalMin.class);
    if (minAnno == null) return propertyModel;

    String hint = "";
    if (minAnno.inclusive())
        hint += " (值大于等于" + minAnno.value() + ")";
    else
        hint += " (值大于" + minAnno.value() + ")";
    propertyModel.setDescription(
            TextUtils.combine(propertyModel.getDescription(), hint)
    );
    return propertyModel;
}
 
Example 3
Source File: JavaxValidationModule.java    From jsonschema-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Determine a number type's minimum (exclusive) value.
 *
 * @param member the field or method to check
 * @return specified exclusive minimum value (or null)
 * @see DecimalMin
 * @see Positive
 */
protected BigDecimal resolveNumberExclusiveMinimum(MemberScope<?, ?> member) {
    DecimalMin decimalMinAnnotation = this.getAnnotationFromFieldOrGetter(member, DecimalMin.class, DecimalMin::groups);
    if (decimalMinAnnotation != null && !decimalMinAnnotation.inclusive()) {
        return new BigDecimal(decimalMinAnnotation.value());
    }
    Positive positiveAnnotation = this.getAnnotationFromFieldOrGetter(member, Positive.class, Positive::groups);
    if (positiveAnnotation != null) {
        return BigDecimal.ZERO;
    }
    return null;
}
 
Example 4
Source File: DecimalMinPropertyValidator.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(DecimalMin minValue) {
    this.minValue = new BigDecimal(minValue.value() );
    this.inclusive = minValue.inclusive();
}