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

com.yhzdys.myosotis.data.CachedConfig Maven / Gradle / Ivy

There is a newer version: 1.3.4
Show newest version
package com.yhzdys.myosotis.data;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public final class CachedConfig {

    /**
     * >
     */
    private final Map> configs = new ConcurrentHashMap<>(2);

    public void add(String namespace) {
        configs.computeIfAbsent(namespace, k -> new ConcurrentHashMap<>(2));
    }

    public void add(String namespace, String configKey, String configValue) {
        configs.computeIfAbsent(namespace, k -> new ConcurrentHashMap<>(2)).put(configKey, configValue);
    }

    public void remove(String namespace, String configKey) {
        Map configs = this.configs.get(namespace);
        if (configs == null) {
            return;
        }
        configs.remove(configKey);
        if (configs.isEmpty()) {
            this.configs.remove(namespace);
        }
    }

    public String get(String namespace, String configKey) {
        Map configs = this.configs.get(namespace);
        if (configs == null) {
            return null;
        }
        return configs.get(configKey);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy