public void setValidationGroups(String validationGroups) {

        clearInitialState();        
        String newValidationGroups = validationGroups;
        
        // treat empty list as null
        if (newValidationGroups != null && newValidationGroups.matches(EMPTY_VALIDATION_GROUPS_PATTERN)) {
            newValidationGroups = null;
        }
        
        // only clear cache of validation group classes if value is changing
        if (newValidationGroups == null && validationGroups != null) {
            cachedValidationGroups = null;
        }
        
        if (newValidationGroups != null && validationGroups != null && !newValidationGroups.equals(validationGroups)) {
            cachedValidationGroups = null;
        }
        
        if (newValidationGroups != null && validationGroups == null) {
            cachedValidationGroups = null;
        }
        
        this.validationGroups = newValidationGroups;
    }