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

io.github.tt432.eyelib.util.data.Blackboard Maven / Gradle / Ivy

There is a newer version: 21.1.7
Show newest version
package io.github.tt432.eyelib.util.data;

import java.util.HashMap;
import java.util.Map;

/**
 * @author TT432
 */
public final class Blackboard {
    private final Map data = new HashMap<>();

    public void put(String key, Object value) {
        data.put(key, value);
    }

    @SuppressWarnings("unchecked")
    public  T getOrDefault(String key, T defaultValue) {
        return (T) data.getOrDefault(key, defaultValue);
    }

    @SuppressWarnings("unchecked")
    public  T get(String key) {
        return (T) data.get(key);
    }

    @SuppressWarnings("unchecked")
    public  T getOrCreate(String key, T defaultValue) {
        return (T) data.computeIfAbsent(key, k -> defaultValue);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy