package com.cf.imes.module.executor.validation.manage.placeStyle;


import com.cf.imes.module.executor.enums.manage.remainPlate.RemainPlatePlaceStyleEnum;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * 放置样式校验
 */
public class PlaceStyleValidator implements ConstraintValidator<ValidPlaceStyle, Integer> {

    private ValidPlaceStyle annotation;

    @Override
    public void initialize(ValidPlaceStyle constraintAnnotation) {
        this.annotation = constraintAnnotation;
    }

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (value == null) {
            value = RemainPlatePlaceStyleEnum.ZERO.getStatus(); // 默认值为正面
        }
        return value == RemainPlatePlaceStyleEnum.ONE.getStatus()
                || value == RemainPlatePlaceStyleEnum.TWO.getStatus()
                || value == RemainPlatePlaceStyleEnum.THREE.getStatus()
                || value == RemainPlatePlaceStyleEnum.FOUR.getStatus()
                || value == RemainPlatePlaceStyleEnum.FIVE.getStatus()
                || value == RemainPlatePlaceStyleEnum.SIX.getStatus()
                || value == RemainPlatePlaceStyleEnum.SEVEN.getStatus()
                || value == RemainPlatePlaceStyleEnum.ZERO.getStatus();
    }
}
