package io.github.vcuswimlab.stackintheflow.controller.component;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;

/**
 * <h1>PersistProfileComponent</h1>
 * Created on: 8/1/2017
 *
 * @author Tyler John Haden
 */

@State(
        name = "ProfileState", storages = {
        @Storage(
                id = "stack-overflow",
                file = "$PROJECT_CONFIG_DIR$/stackoverflow-profile.xml")
})
public class PersistProfileComponent implements PersistentStateComponent<PersistProfileComponent> {

    private Map<String, Integer> userStatMap;

    public Map<String, Integer> getUserStatMap() {
        return userStatMap;
    }

    @Override
    public void noStateLoaded() {
        userStatMap = new HashMap<>();
    }

    @Override
    public void loadState(PersistProfileComponent state) {
        XmlSerializerUtil.copyBean(state, this);
    }

    @Nullable
    @Override
    public PersistProfileComponent getState() {
        return this;
    }

}

@@ -534,93 +534,9 @@
 age(
-%0A                id = %22stack-overflow%22,%0A                file = %22$PROJECT_CONFIG_DIR$/
+%22
 stac
@@ -672,14 +672,13 @@
    p
-rivate
+ublic
  Map

Fix user profile not serializing.