package json;

import json.standard.StandardJSONArray;
import json.standard.StandardJSONObject;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * Created by Alex on 8/18/2017.
 */
final class JSONMapHelper
{
    public static <K, V> Map<K, V> extractMap(JSONArray array, BiFunction<JSONObject, String, K> getKeyAt, BiFunction<JSONObject, String, V> getValueAt)
    {
        Map<K, V> map = new HashMap<>(array.size());

        for(int i = 0; i < array.size(); i++)
            map.put(getKeyAt.apply(array.getObjectAt(i), MAP_KEY_TAG), getValueAt.apply(array.getObjectAt(i), MAP_VALUE_TAG));

        return map;
    }

    public static <K, V> JSONArray jsonifyMap(Map<K, V> map, Function<K, JSONValue> keyToJSON, Function<V, JSONValue> valueToJSON)
    {
        JSONArray array = new StandardJSONArray();

        for(Map.Entry<K, V> entry : map.entrySet())
        {
            JSONObject jsonEntry = new StandardJSONObject();
            jsonEntry.put(MAP_KEY_TAG, keyToJSON.apply(entry.getKey()));
            jsonEntry.put(MAP_VALUE_TAG, valueToJSON.apply(entry.getValue()));
            array.add(jsonEntry);
        }

        return array;
    }

    static final String MAP_KEY_TAG = "k", MAP_VALUE_TAG = "v";
}

@@ -225,68 +225,1203 @@
  * C
-reated by Alex on 8/18/2017.%0A */%0Afinal class JSONMapHelper%0A%7B
+ontains helper methods which transforms implementations of %7B@link Map%7D to/from a %7B@link JSONArray%7D.%0A *%0A * @author Alex%0A */%0Apublic final class JSONMapHelper%0A%7B%0A    /**%0A     * Constructs a %7B@link Map%7D from the provided %7B@link JSONArray%7D.%0A     *%0A     * It is assumed that the %7B@link JSONArray%7D only contains %7B@link JSONObject%7Ds and these contain%0A     * the default keys used when %7B@link JSONMapHelper#jsonifyMap(Map, Function, Function)%7D was used to%0A     * transform the map into a %7B@link JSONArray%7D.%0A     *%0A     * Note: this method serves as the inverse operation of %7B@link JSONMapHelper#jsonifyMap(Map, Function, Function)%7D%0A     *%0A     * @param array      The array of key-value pairs%0A     * @param getKeyAt   A function which can extract a key from a %7B@link JSONObject%7D given the key's tag%0A     * @param getValueAt A function which can extract a value from a %7B@link JSONObject%7D given the value's tag%0A     * @param %3CK%3E        The type of object which the returned %7B@link Map%7D uses for its keys.%0A     * @param %3CV%3E        The type of object which the returned %7B@link Map%7D uses for its values.%0A     * @return A %7B@link Map%7D which contains the keys an values which were in the %7B@link JSONArray%7D%0A     */
 %0A   
@@ -1733,19 +1733,23 @@
 tAt(i), 
-MAP
+DEFAULT
 _KEY_TAG
@@ -1790,19 +1790,23 @@
 tAt(i), 
-MAP
+DEFAULT
 _VALUE_T
@@ -1835,24 +1835,814 @@
 map;%0A    %7D%0A%0A
+    /**%0A     * Constructs a %7B@link JSONArray%7D from the provided %7B@link Map%7D.%0A     *%0A     * Note: this method serves as the inverse operation of %7B@link JSONMapHelper#extractMap(JSONArray, BiFunction, BiFunction)%7D%0A     *%0A     * @param map         The %7B@link Map%7D to be transcribed to a %7B@link JSONArray%7D%0A     * @param keyToJSON   A function which can transform a %7B@link K%7D to a %7B@link JSONValue%7D%0A     * @param valueToJSON A function which can transform a %7B@link V%7D to a %7B@link JSONValue%7D%0A     * @param %3CK%3E        The type of object which the returned %7B@link Map%7D uses for its keys.%0A     * @param %3CV%3E        The type of object which the returned %7B@link Map%7D uses for its values.%0A     * @return A %7B@link JSONArray%7D which holds the the contents of the %7B@param map%7D as %7B@link JSONValue%7Ds%0A     */%0A
     public s
@@ -2967,19 +2967,23 @@
 try.put(
-MAP
+DEFAULT
 _KEY_TAG
@@ -3044,19 +3044,23 @@
 try.put(
-MAP
+DEFAULT
 _VALUE_T
@@ -3179,16 +3179,24 @@
  %7D%0A%0A    
+private 
 static f
@@ -3207,19 +3207,23 @@
  String 
-MAP
+DEFAULT
 _KEY_TAG
@@ -3234,11 +3234,15 @@
 k%22, 
-MAP
+DEFAULT
 _VAL

Add JavaDoc to MapHelper