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

com.maxifier.mxcache.impl.caches.def.ObjectObjectTroveStorage Maven / Gradle / Ivy

/*
 * Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
 */
package com.maxifier.mxcache.impl.caches.def;

import com.maxifier.mxcache.storage.ObjectObjectStorage;
import gnu.trove.map.hash.TCustomHashMap;
import gnu.trove.strategy.HashingStrategy;

/**
 * ObjectObjectTroveStorage
 *
 * @author Andrey Yakoushin ([email protected])
 * @author Alexander Kochurov ([email protected])
 */
public class ObjectObjectTroveStorage extends TCustomHashMap implements ObjectObjectStorage {
    public ObjectObjectTroveStorage() {
        //noinspection unchecked
        super(DEFAULT_HASHING_STRATEGY);
    }

    public ObjectObjectTroveStorage(HashingStrategy strategy) {
        super(strategy);        
    }

    @Override
    public Object load(K key) {
        Object v = get(key);
        if (v == null) {
            return UNDEFINED;
        }
        if (v == TroveHelper.NULL_REPLACEMENT) {
            return null;
        }
        return v;
    }

    @Override
    public void save(K key, V value) {
        put(key, value == null ? TroveHelper.NULL_REPLACEMENT : value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy