class ValidEnumValueOrProfileAttributeValidator implements
        ConstraintValidator<ValidEnumValueOrProfileAttribute, String>, ValidationErrorDescriptorBuilder {

    @Override
    public void initialize(ValidEnumValueOrProfileAttribute constraintAnnotation) {
        Object[] constants = constraintAnnotation.enumClass().getEnumConstants();
        errorCode = constraintAnnotation.message();
        if(constants == null){
            throw new IllegalStateException("enumClass [" + constraintAnnotation.enumClass() + "]is not enum");
        }
        for (Object constant : constants) {
            enumNames.add(constant.toString());
        }
    }

}