package com.face.global.validator.enums;


import com.face.global.validator.EnumValidator;
import com.face.global.validator.impl.EnumConstraintValidator;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

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

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 枚举检查注解
 *
 */
@Documented
@Constraint(validatedBy = EnumConstraintValidator.class)
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Repeatable(EnumCheck.List.class)
public @interface EnumCheck {
    /**
     * 提示信息
     *
     */
    String message() default "{javax.validation.constraints.EnumCheck.message}";

    /**
     * 分组
     *
     */
    Class<?>[] groups() default { };

    /**
     * 扩展对象
     *
     */
    Class<? extends Payload>[] payload() default { };

    /**
     * 必须实现EnumValidator接口的枚举类
     *
     */
    Class<? extends EnumValidator>  clazz();

    /**
     * 调用的方法名称
     */
    String method() default "getValue";

    /**
     * Defines several {@code @In} constraints on the same element.
     *
     * @see EnumCheck
     */
    @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
    @Retention(RUNTIME)
    @Documented
    @interface List {
        /**
         * In数组
         */
        EnumCheck[] value();
    }
}