All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.lightoze.gwt.i18n.server.FallbackChainLocaleProvider Maven / Gradle / Ivy

There is a newer version: 0.26
Show newest version
package net.lightoze.gwt.i18n.server;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;

/**
 * @author Vladimir Kulev
 */
public class FallbackChainLocaleProvider implements LocaleProvider {
    private LinkedList chain = new LinkedList();

    public FallbackChainLocaleProvider(List chain) {
        this.chain.addAll(chain);
    }

    public void addLast(LocaleProvider provider) {
        chain.addLast(provider);
    }

    public void addFirst(LocaleProvider provider) {
        chain.addFirst(provider);
    }

    public void remove(LocaleProvider provider) {
        chain.remove(provider);
    }

    public List getChain() {
        return Collections.unmodifiableList(chain);
    }

    @Override
    public Locale getLocale() {
        for (LocaleProvider provider : chain) {
            Locale locale = provider.getLocale();
            if (locale != null) {
                return locale;
            }
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy