package cn.report.excel.easyexcel.api.cache;

import java.util.ArrayList;
import java.util.List;

import cn.report.excel.easyexcel.api.context.AnalysisContext;

/**
 * Putting temporary data directly into a map is a little more efficient but very memory intensive
 *
 * @author Jiaju Zhuang
 */
public class MapCache implements ReadCache {
    private final List<String> cache = new ArrayList<>();

    @Override
    public void init(AnalysisContext analysisContext) {}

    @Override
    public void put(String value) {
        cache.add(value);
    }

    @Override
    public String get(Integer key) {
        if (key == null || key < 0) {
            return null;
        }
        return cache.get(key);
    }

    @Override
    public void putFinished() {}

    @Override
    public void destroy() {}

}
