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

net.fortuna.ical4j.util.MapTimeZoneCache Maven / Gradle / Ivy

There is a newer version: 3.0.22
Show newest version
package net.fortuna.ical4j.util;

import net.fortuna.ical4j.model.component.VTimeZone;

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

public class MapTimeZoneCache implements TimeZoneCache {

    private final Map mapCache;

    public MapTimeZoneCache() {
        mapCache = new ConcurrentHashMap<>();
    }

    @Override
    public VTimeZone getTimezone(String id) {
        return mapCache.get(id);
    }

    @Override
    public boolean putIfAbsent(String id, VTimeZone timeZone) {
        VTimeZone v = mapCache.get(id);
        if (v == null) {
            v = mapCache.put(id, timeZone);
            return true;
        } else {
            return false;
        }
    }

    @Override
    public boolean containsId(String id) {
        return mapCache.containsKey(id);
    }

    @Override
    public void clear() {
        mapCache.clear();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy