これが私の見解です。できるだけシンプルにしようとしました。
インターフェース:
@Target({TYPE, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Constraint(validatedBy = OneOfValidator.class)
@Documented
public @interface OneOf {
    String message() default "{one.of.message}";
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {};
    String[] value();
}
検証の実装:
public class OneOfValidator implements ConstraintValidator<OneOf, Object> {
    private String[] fields;
    @Override
    public void initialize(OneOf annotation) {
        this.fields = annotation.value();
    }
    @Override
    public boolean isValid(Object value, ConstraintValidatorContext context) {
        BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(value);
        int matches = countNumberOfMatches(wrapper);
        if (matches > 1) {
            setValidationErrorMessage(context, "one.of.too.many.matches.message");
            return false;
        } else if (matches == 0) {
            setValidationErrorMessage(context, "one.of.no.matches.message");
            return false;
        }
        return true;
    }
    private int countNumberOfMatches(BeanWrapper wrapper) {
        int matches = 0;
        for (String field : fields) {
            Object value = wrapper.getPropertyValue(field);
            boolean isPresent = detectOptionalValue(value);
            if (value != null && isPresent) {
                matches++;
            }
        }
        return matches;
    }
    private boolean detectOptionalValue(Object value) {
        if (value instanceof Optional) {
            return ((Optional) value).isPresent();
        }
        return true;
    }
    private void setValidationErrorMessage(ConstraintValidatorContext context, String template) {
        context.disableDefaultConstraintViolation();
        context
            .buildConstraintViolationWithTemplate("{" + template + "}")
            .addConstraintViolation();
    }
}
使用法:
@OneOf({"stateType", "modeType"})
public class OneOfValidatorTestClass {
    private StateType stateType;
    private ModeType modeType;
}
メッセージ:
one.of.too.many.matches.message=Only one of the following fields can be specified: {value}
one.of.no.matches.message=Exactly one of the following fields must be specified: {value}
     
              
Object)。この場合、値を取得するためにリフレクションを使用する必要はありませんが、この場合、バリデーターは一般的ではなくなります2)BeanWrapperImpSpring Framework(または他のライブラリ)とそのgetPropertyValue()メソッドから使用します。この場合、として値を取得し、Object必要な任意のタイプにキャストできます。