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

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

Go to download

Extension for BeanValidation API Core. Content interfaces, qualifiers and constraints definitions. This version is Java 17 and JakartaEE 10 compatible.

The newest version!
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 jakarta.validation.Constraint;
import jakarta.validation.Payload;

import com.github.ldeitos.validators.EmptyValidator;

/**
 * The annotated element must be empty.
 * 

* Supported types are: *

    *
  • {@code CharSequence} (length of character sequence is evaluated)
  • *
  • {@code Collection} (collection size is evaluated)
  • *
  • {@code Map} (map size is evaluated)
  • *
  • Array (array length is evaluated)
  • *
*

* {@code null} elements are considered valid. * * @author Leandro Deitos * */ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @Constraint(validatedBy = { EmptyValidator.class }) public @interface Empty { /** * @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 "{com.github.ldeitos.Empty.message}"; Class[] groups() default {}; Class[] payload() default {}; /** * Defines several {@link Empty} annotations on the same element. * * @see Empty */ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @interface List { Empty[] value(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy