com.maxifier.mxcache.impl.caches.storage.StorageByteCacheImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mxcache-runtime Show documentation
Show all versions of mxcache-runtime Show documentation
Constains all classes necessary for launching a MxCache-instrumentated application
/*
* Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
*/
package com.maxifier.mxcache.impl.caches.storage;
import com.maxifier.mxcache.impl.MutableStatistics;
import com.maxifier.mxcache.impl.caches.abs.*;
import com.maxifier.mxcache.caches.*;
import com.maxifier.mxcache.storage.*;
import com.maxifier.mxcache.interfaces.Statistics;
import com.maxifier.mxcache.interfaces.StatisticsHolder;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* THIS IS GENERATED CLASS! DON'T EDIT IT MANUALLY!
*
* GENERATED FROM StorageP2PCache.template
*
* @author Andrey Yakoushin ([email protected])
* @author Alexander Kochurov ([email protected])
*/
public class StorageByteCacheImpl extends AbstractByteCache implements StorageHolder {
private static final long serialVersionUID = 100L;
private ByteStorage storage;
public StorageByteCacheImpl(Object owner, ByteCalculatable calculatable, @Nonnull MutableStatistics statistics) {
super(owner, calculatable, statistics);
}
@Override
public void setStorage(@Nonnull ByteStorage storage) {
if (this.storage != null) {
throw new UnsupportedOperationException("Storage already set");
}
this.storage = storage;
}
@Override
public boolean isCalculated() {
return storage.isCalculated();
}
@Override
public byte load() {
return storage.load();
}
@Override
public void save(byte value) {
storage.save(value);
}
@Override
public void clear() {
storage.clear();
}
@Override
public int size() {
return storage.size();
}
@Nullable
@Override
public Statistics getStatistics() {
if (storage instanceof StatisticsHolder) {
return ((StatisticsHolder)storage).getStatistics();
}
return super.getStatistics();
}
}