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

com.github.ldeitos.constraint.Digits Maven / Gradle / Ivy

package com.github.ldeitos.constraint;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import com.github.ldeitos.validators.DigitsValidator;

/**
 * The annotated element must be a number within accepted range
 * Supported types are:
 * 
    *
  • {@code BigDecimal}
  • *
  • {@code BigInteger}
  • *
  • {@code CharSequence}
  • *
  • {@code byte}, {@code short}, {@code int}, {@code long}, and their respective * wrapper types
  • *
*

* {@code null} elements are considered valid. * * @author Emmanuel Bernard */ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @Constraint(validatedBy = { DigitsValidator.class }) public @interface Digits { /** * @return Parameter array to be interpolated at message. Parameters can be informed in * "key=value" or just "value" pattern.
* e.g:
*
* message="My {par1} message"
* messageParameters = {"par1=parameterized"}
*
* message="My {0} message"
* messageParameters = {"parameterized"} */ String[] messageParameters() default {}; String message() default "{javax.validation.constraints.Digits.message}"; Class[] groups() default { }; Class[] payload() default { }; /** * @return maximum number of integral digits accepted for this number */ int integer(); /** * @return maximum number of fractional digits accepted for this number */ int fraction(); /** * Defines several {@link Digits} annotations on the same element. * * @see Digits */ @Target( { METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) @Retention(RUNTIME) @Documented @interface List { Digits[] value(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy