class DefaultPreferenceScopeResolver implements PreferenceScopeResolver {

    @Override
    public PreferenceScope resolve(final String... scopeTypes) {
        if (scopeTypes != null && scopeTypes.length >= 1 && scopeTypes.length <= 2) {
            if (scopeTypes.length == 2) {
                return getScopeFromOrder(scopeTypes);
            }

            String scopeType = scopeTypes[0];

            if (scopeType.equals(DefaultScopes.USER.type())) {
                return getScopeFromOrder(DefaultScopes.USER.type(),
                                         DefaultScopes.ENTIRE_APPLICATION.type());
            } else if (scopeType.equals(DefaultScopes.ALL_USERS.type())) {
                return getScopeFromOrder(DefaultScopes.ALL_USERS.type(),
                                         DefaultScopes.ENTIRE_APPLICATION.type());
            } else if (scopeType.equals(DefaultScopes.COMPONENT.type())) {
                return getScopeFromOrder(DefaultScopes.ALL_USERS.type(),
                                         DefaultScopes.COMPONENT.type());
            } else if (scopeType.equals(DefaultScopes.ENTIRE_APPLICATION.type())) {
                return getScopeFromOrder(DefaultScopes.ALL_USERS.type(),
                                         DefaultScopes.ENTIRE_APPLICATION.type());
            }
        }

        throw new InvalidPreferenceScopeException("The passed scope types are invalid.");
    }

    public  DefaultPreferenceScopeResolver(@MapsTo("order") final List<PreferenceScope> order);

}