package com.atlassian.stash.internal.i18n.cache;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Locale;

import static com.atlassian.bitbucket.util.Chainable.chain;

public class MessageLocaleMap<V> {

    private final MessageMap<V> messages;
    private final Iterable<Locale> locales;

    public MessageLocaleMap(MessageMap<V> messages, Iterable<Locale> locales) {
        this.messages = messages;
        this.locales = locales;
    }

    @Nullable
    public V get(@Nonnull String key) {
        return messages.get(key, locales);
    }

    @Nonnull
    public Iterable<String> keySet() {
        // Technically we're returning a bad set of locales here
        return chain(messages.keySet()).transform(MessageKey.TO_KEY);
    }
}
