package co.phoenixlab.common.localization;

import java.util.*;

public class LocalizerImpl implements Localizer {

    private final Locale locale;
    private final LinkedHashSet<LocaleStringProvider> providers;
    private final Collection<LocaleStringProvider> providersUnmodifiable;

    public LocalizerImpl(Locale locale) {
        Objects.requireNonNull(locale, "Locale cannot be null");
        this.locale = locale;
        this.providers = new LinkedHashSet<>();
        this.providersUnmodifiable = Collections.unmodifiableCollection(providers);
    }

    @Override
    public Locale getLocale() {
        return locale;
    }

    @Override
    public void addLocaleStringProvider(LocaleStringProvider provider) {
        Objects.requireNonNull(provider, "Provider cannot be null");
        provider.setActiveLocale(locale);
        providers.add(provider);
    }

    @Override
    public void removeLocaleStringProvider(LocaleStringProvider provider) {
        Objects.requireNonNull(provider, "Provider cannot be null");
        providers.remove(provider);
    }

    @Override
    public Collection<LocaleStringProvider> getLocaleStringProviders() {
        return providersUnmodifiable;
    }

    @Override
    public void removeAllLocaleStringProviders() {
        providers.clear();
    }

    @Override
    public boolean containsKey(String key) {
        return providers.stream().
                anyMatch(p -> p.contains(key));
    }

    @Override
    public String localize(String key) {
        return null;
    }

    @Override
    public String localize(String key, Object arg0) {
        return null;
    }

    @Override
    public String localize(String key, Object arg0, Object arg1) {
        return null;
    }

    @Override
    public String localize(String key, Object... args) {
        return null;
    }

    @Override
    public String localizeOrDefault(String key, String def) {
        return null;
    }

    @Override
    public String localizeOrDefault(String key, String def, Object arg0) {
        return null;
    }

    @Override
    public String localizeOrDefault(String key, String def, Object arg0, Object arg1) {
        return null;
    }

    @Override
    public String localizeOrDefault(String key, String def, Object... args) {
        return null;
    }
}

@@ -109,16 +109,71 @@
 izer %7B%0A%0A
+    private static final String NULL_KEY = %22nullkey%22;%0A%0A
     priv
@@ -1556,32 +1556,99 @@
 e(String key) %7B%0A
+        if (key == null) %7B%0A            return NULL_KEY;%0A        %7D%0A%0A
         return n
@@ -1719,32 +1719,99 @@
  Object arg0) %7B%0A
+        if (key == null) %7B%0A            return NULL_KEY;%0A        %7D%0A%0A
         return n
@@ -1895,32 +1895,99 @@
  Object arg1) %7B%0A
+        if (key == null) %7B%0A            return NULL_KEY;%0A        %7D%0A%0A
         return n
@@ -2061,32 +2061,99 @@
 ject... args) %7B%0A
+        if (key == null) %7B%0A            return NULL_KEY;%0A        %7D%0A%0A
         return n
@@ -2236,24 +2236,86 @@
 ring def) %7B%0A
+        if (key == null) %7B%0A            return def;%0A        %7D%0A%0A
         retu
@@ -2411,32 +2411,94 @@
  Object arg0) %7B%0A
+        if (key == null) %7B%0A            return def;%0A        %7D%0A%0A
         return n
@@ -2603,32 +2603,94 @@
  Object arg1) %7B%0A
+        if (key == null) %7B%0A            return def;%0A        %7D%0A%0A
         return n
@@ -2785,32 +2785,94 @@
 ject... args) %7B%0A
+        if (key == null) %7B%0A            return def;%0A        %7D%0A%0A
         return n

Implement null checks