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

io.quarkus.cache.runtime.AbstractCache Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
package io.quarkus.cache.runtime;

import io.quarkus.cache.Cache;
import io.quarkus.cache.DefaultCacheKey;

public abstract class AbstractCache implements Cache {

    public static final String NULL_KEYS_NOT_SUPPORTED_MSG = "Null keys are not supported by the Quarkus application data cache";

    private Object defaultKey;

    @Override
    public Object getDefaultKey() {
        if (defaultKey == null) {
            defaultKey = new DefaultCacheKey(getName());
        }
        return defaultKey;
    }

    @Override
    @SuppressWarnings("unchecked")
    public  T as(Class type) {
        if (type.isInstance(this)) {
            return (T) this;
        } else {
            throw new IllegalStateException("This cache is not an instance of " + type.getName());
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy