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

com.lyncode.xliff.cache.InMemoryPersistentXliffCache Maven / Gradle / Ivy

The newest version!
package com.lyncode.xliff.cache;

import com.google.common.base.Supplier;
import com.lyncode.xliff.XLIFF;

import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Callable;

public class InMemoryPersistentXliffCache implements XliffCache {
    private final Locale defaultLocale;
    private final Map> map = new HashMap>();

    public InMemoryPersistentXliffCache(Locale defaultLocale) {
        this.defaultLocale = defaultLocale;
    }

    @Override
    public Collection get(Locale locale, Supplier> initializer) {
        if (locale == null) locale = defaultLocale;

        if (!map.containsKey(locale))
            map.put(locale, initializer.get());

        return map.get(locale);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy