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

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

Go to download

Constains all classes necessary for launching a MxCache-instrumentated application

There is a newer version: 2.6.9
Show newest version
/*
 * Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
 */
package com.maxifier.mxcache.impl.caches.def;

import com.maxifier.mxcache.storage.BooleanObjectStorage;

/**
 * BooleanObjectTroveStorage
 *
 * @author Andrey Yakoushin ([email protected])
 * @author Alexander Kochurov ([email protected])
 */
public class BooleanObjectTroveStorage implements BooleanObjectStorage {
    private Object trueValue = UNDEFINED;
    private Object falseValue = UNDEFINED;

    @Override
    public Object load(boolean o) {
        return o ? trueValue : falseValue;
    }

    @Override
    public void save(boolean o, V t) {
        if (o) {
            trueValue = t;
        } else {
            falseValue = t;
        }
    }

    @Override
    public void clear() {
        trueValue = UNDEFINED;
        falseValue = UNDEFINED;
    }

    @Override
    public int size() {
        int res = 0;
        if (trueValue != UNDEFINED) {
            res++;
        }
        if (falseValue != UNDEFINED) {
            res++;
        }
        return res;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy