package org.jabref.gui.entryeditor;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.LinkedHashMap;

import org.jabref.preferences.JabRefPreferences;

/**
 * Class for creating the information about customizable entry editor tabs.
 */
public final class EntryEditorTabList {

    private EntryEditorTabList() {

    }

    public static Map<String, List<String>> create(JabRefPreferences preferences) {
        Map<String, List<String>> tabs = new LinkedHashMap<>();
        int i = 0;
        String name;
        if (preferences.hasKey(JabRefPreferences.CUSTOM_TAB_NAME + 0)) {
            // The user has modified from the default values:
            while (preferences.hasKey(JabRefPreferences.CUSTOM_TAB_NAME + i)) {
                name = preferences.get(JabRefPreferences.CUSTOM_TAB_NAME + i);
                List<String> entry = Arrays
                        .asList(preferences.get(JabRefPreferences.CUSTOM_TAB_FIELDS + i).split(";"));
                tabs.put(name, entry);
                i++;
            }
        } else {
            // Nothing set, so we use the default values:
            while (preferences.get(JabRefPreferences.CUSTOM_TAB_NAME + "_def" + i) != null) {
                name = preferences.get(JabRefPreferences.CUSTOM_TAB_NAME + "_def" + i);
                List<String> entry = Arrays
                        .asList(preferences.get(JabRefPreferences.CUSTOM_TAB_FIELDS + "_def" + i).split(";"));
                tabs.put(name, entry);
                i++;
            }
        }
        return tabs;
    }
}

@@ -74,18 +74,27 @@
 .util.Li
-st
+nkedHashMap
 ;%0Aimport
@@ -104,19 +104,20 @@
 va.util.
-Map
+List
 ;%0Aimport
@@ -123,34 +123,24 @@
 t java.util.
-LinkedHash
 Map;%0A%0Aimport

Fix checkstyle error.