<commit_before>package seedu.taskmanager.model;

import java.util.ArrayList;
import java.util.logging.Logger;

import com.google.common.eventbus.Subscribe;

import seedu.taskmanager.commons.core.ComponentManager;
import seedu.taskmanager.commons.core.LogsCenter;
import seedu.taskmanager.commons.events.model.TaskManagerChangedEvent;
import seedu.taskmanager.storage.StorageManager;

// @@author A0140032E
/**
 * Represents the History of user commands in this session
 */
public class HistoryManager extends ComponentManager {

    private final Model model;
    private static HistoryManager instance = null;
    private static final Logger logger = LogsCenter.getLogger(StorageManager.class);
    private ArrayList<ReadOnlyTaskManager> historyList;
    private ArrayList<ReadOnlyTaskManager> futureList;

    public static final String INITIALIZATION_ERROR = "HistoryManager has not been initialized with a Model yet";


    protected HistoryManager(Model model) {
        super();
        this.model = model;

        historyList = new ArrayList<ReadOnlyTaskManager>();
        futureList = new ArrayList<ReadOnlyTaskManager>();

        TaskManager taskManager = new TaskManager(model.getTaskManager());
        historyList.add(taskManager);
    }

    public static HistoryManager createInstance(Model model) {
        instance = new HistoryManager(model);
        return instance;
    }
    public static HistoryManager getInstance() {
        if (instance == null) {
            throw new NullPointerException(INITIALIZATION_ERROR);
        }
        return instance;
    }

    @Subscribe
    public void handleTaskManagerChangedEvent(TaskManagerChangedEvent event) {
        logger.info(LogsCenter.getEventHandlingLogMessage(event, "Local data changed, updating history manager"));
        TaskManager taskManager = new TaskManager(event.data);
        historyList.add(taskManager);
    }

    private ReadOnlyTaskManager getMostRecentHistory() {
        if (historyList.size() < 2) {
            throw new NullPointerException();
        }
        ReadOnlyTaskManager t = historyList.remove(historyList.size() - 1);
        futureList.add(new TaskManager(t));
        return historyList.remove(historyList.size() - 1);<commit_msg>remove history after load/move command<commit_after>package seedu.taskmanager.model;

import java.util.ArrayList;
import java.util.logging.Logger;

import com.google.common.eventbus.Subscribe;

import seedu.taskmanager.commons.core.ComponentManager;
import seedu.taskmanager.commons.core.LogsCenter;
import seedu.taskmanager.commons.events.model.TaskManagerChangedEvent;
import seedu.taskmanager.commons.events.storage.TaskManagerStorageDirectoryChangedEvent;
import seedu.taskmanager.storage.StorageManager;

// @@author A0140032E
/**
 * Represents the History of user commands in this session
 */
public class HistoryManager extends ComponentManager {

    private final Model model;
    private static HistoryManager instance = null;
    private static final Logger logger = LogsCenter.getLogger(StorageManager.class);
    private ArrayList<ReadOnlyTaskManager> historyList;
    private ArrayList<ReadOnlyTaskManager> futureList;

    public static final String INITIALIZATION_ERROR = "HistoryManager has not been initialized with a Model yet";

    protected HistoryManager(Model model) {
        super();
        this.model = model;

        historyList = new ArrayList<ReadOnlyTaskManager>();
        futureList = new ArrayList<ReadOnlyTaskManager>();

        TaskManager taskManager = new TaskManager(model.getTaskManager());
        historyList.add(taskManager);
    }

    public static HistoryManager createInstance(Model model) {
        instance = new HistoryManager(model);
        return instance;
    }

    public static HistoryManager getInstance() {
        if (instance == null) {
            throw new NullPointerException(INITIALIZATION_ERROR);
        }
        return instance;
    }

    @Subscribe
    public void handleTaskManagerChangedEvent(TaskManagerChangedEvent event) {
        TaskManager taskManager = new TaskManager(event.data);
        historyList.add(taskManager);
        logger.info(LogsCenter.getEventHandlingLogMessage(event,
                ("Local data changed, updating history manager. Histories = " + historyList.size() + " Futures = "
                        + futureList.size())));
    }

    @Subscribe
    public void handleTaskManagerStorageDirectoryChangedEvent(TaskManagerStorageDirectoryChangedEvent event) {
        historyList = new ArrayList<ReadOnlyTaskManager>();
        futureList = new ArrayList<ReadOnlyTaskManager>();
        logger.info(LogsCenter.getEventHandlingLogMessage(event,
                ("Storage file location changed, resetting history. Histories = " + historyList.size() + " Futures = "
                        + futureList.size())));
    }

    private ReadOnlyTaskManager getMostRecentHistory() {
        if (historyList.size() < 2) {
            throw new NullPointerException();
        }
        ReadOnlyTaskManager t = historyList.remove(historyList.size() - 1);
        futureList.add(new TaskManager(t));
        return historyList.remove(historyList.size() - 1);
{'fraction_non_alphanumeric': 0.0845368765646062, 'fraction_numerical': 0.0038513383400731755, 'mean_word_length': 3.580246913580247, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1459765', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1276, 'n_words': 313}