package io.tetrapod.core.utils;

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

public class PrefMap {

   private final Map<String, String> prefs = new HashMap<>();

   public String getPref(String key, String def) {
      return prefs.containsKey(key) ? prefs.get(key) : def;
   }

   public boolean getPref(String key, boolean def) {
      return prefs.containsKey(key) ? Boolean.parseBoolean(prefs.get(key)) : def;
   }

   public int getPref(String key, int def) {
      return prefs.containsKey(key) ? Integer.parseInt(prefs.get(key)) : def;
   }

   public long getPref(String key, long def) {
      return prefs.containsKey(key) ? Long.parseLong(prefs.get(key)) : def;
   }

   public void setPref(String key, String val) {
      prefs.put(key, val);
   }

   public void setPref(String key, boolean val) {
      prefs.put(key, Boolean.toString(val));
   }

   public void setPref(String key, int val) {
      prefs.put(key, Integer.toString(val));
   }

   public void setPref(String key, long val) {
      prefs.put(key, Long.toString(val));
   }

}

@@ -47,37 +47,9 @@
 til.
-HashMap;%0Aimport java.util.Map
+*
 ;%0A%0Ap
@@ -1025,10 +1025,131 @@
 ;%0A   %7D%0A%0A
+   public int size() %7B%0A      return prefs.size();%0A   %7D%0A%0A   public Set%3CString%3E keys() %7B%0A      return prefs.keySet();%0A   %7D%0A
 %7D%0A

update PrefMap