class PreferenceScopeValidatorImpl implements PreferenceScopeValidator {

    @Override
    public void validate(final PreferenceScope scope) throws InvalidPreferenceScopeException {
        if (scope == null) {
            throw new InvalidPreferenceScopeException("A root scope must not be null.");
        }

        for (PreferenceScope currentScope = scope; currentScope != null; currentScope = currentScope.childScope()) {
            final String type = currentScope.type();
            final String key = currentScope.key();

            if (scopeTypes.typeRequiresKey(type) && isEmpty(key)) {
                throw new InvalidPreferenceScopeException("The type " + type + " must be associated with a non empty key.");
            }
        }

        if (!scopeResolutionStrategy.getInfo().order().contains(scope)) {
            throw new InvalidPreferenceScopeException("This scope is not defined in the scope hierarchy.");
        }
    }

    protected  PreferenceScopeValidatorImpl();
    @Inject public  PreferenceScopeValidatorImpl(@Customizable final PreferenceScopeTypes scopeTypes,
                                        @Customizable final PreferenceScopeResolutionStrategy scopeResolutionStrategy);

}