package net.redborder.utils.types.impl;

import net.redborder.utils.types.MappedType;
import net.redborder.utils.types.Type;
import net.redborder.utils.types.TypeManager;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class JsonType implements Type {
    Map<String, Type> types = new HashMap<>();

    public JsonType(Map<String, Object> params) {
        Map<String, Map<String, Object>> components = (Map<String, Map<String, Object>>) params.get("components");

        for (Map.Entry<String, Map<String, Object>> component : components.entrySet()) {
            Type type = TypeManager.newType(component.getValue());
            types.put(component.getKey(), type);
        }
    }

    @Override
    public Object get() {
        Map<String, Object> typeValue = new HashMap<>();

        for (Map.Entry<String, Type> type : types.entrySet()) {
            if (type.getValue() instanceof MappedType) {
                Object value = type.getValue().get();
                typeValue.putAll((Map<String, Object>) value);
            } else {
                typeValue.put(type.getKey(), type.getValue().get());
            }
        }

        return typeValue;
    }
}

@@ -959,62 +959,8 @@
 ) %7B%0A
-                Object value = type.getValue().get();%0A
     
@@ -1014,13 +1014,29 @@
 t%3E) 
-value
+type.getValue().get()
 );%0A 

Fix type check on JsonType (#26)