Java Code Examples for org.eclipse.microprofile.openapi.models.media.Schema#getMaximum()

The following examples show how to use org.eclipse.microprofile.openapi.models.media.Schema#getMaximum() . These examples are extracted from open source projects. 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
void decimalMax(AnnotationTarget target, Schema schema) {
    AnnotationInstance constraint = getConstraint(target, BV_DECIMAL_MAX);

    if (constraint != null && schema.getMaximum() == null) {
        String decimalValue = stringValue(constraint, VALUE);
        try {
            BigDecimal decimal = new BigDecimal(decimalValue);
            schema.setMaximum(decimal);

            Optional<Boolean> inclusive = booleanValue(constraint, INCLUSIVE);

            if (schema.getExclusiveMaximum() == null && inclusive.isPresent() && !inclusive.get()) {
                schema.setExclusiveMaximum(Boolean.TRUE);
            }
        } catch (@SuppressWarnings("unused") NumberFormatException e) {
            DataObjectLogging.log.invalidAnnotationFormat(decimalValue);
        }
    }
}
 
Example 2
void max(AnnotationTarget target, Schema schema) {
    AnnotationInstance constraint = getConstraint(target, BV_MAX);

    if (constraint != null && schema.getMaximum() == null) {
        AnnotationValue value = constraint.value(VALUE);
        schema.setMaximum(new BigDecimal(value.asLong()));
    }
}
 
Example 3
void negative(AnnotationTarget target, Schema schema) {
    AnnotationInstance constraint = getConstraint(target, BV_NEGATIVE);

    if (constraint != null && schema.getMaximum() == null) {
        Boolean exclusive = schema.getExclusiveMaximum();

        if (exclusive != null && exclusive) {
            schema.setMaximum(BigDecimal.ZERO);
        } else {
            schema.setMaximum(NEGATIVE_ONE);
        }
    }
}
 
Example 4
void negativeOrZero(AnnotationTarget target, Schema schema) {
    AnnotationInstance constraint = getConstraint(target, BV_NEGATIVE_OR_ZERO);

    if (constraint != null && schema.getMaximum() == null) {
        Boolean exclusive = schema.getExclusiveMaximum();

        if (exclusive != null && exclusive) {
            schema.setMaximum(BigDecimal.ONE);
        } else {
            schema.setMaximum(BigDecimal.ZERO);
        }
    }
}