package com.wizzardo.tools.evaluation;

import com.wizzardo.tools.collections.CollectionTools;

import java.util.HashMap;

/**
 * Created by wizzardo on 22.12.15.
 */
public class Config extends HashMap<String, Object> implements CollectionTools.Closure<Object, ClosureExpression> {
    @Override
    public Object get(Object key) {
        Object value = super.get(key);
        if (value == null) {
            put((String) key, value = new Config());
        }
        return value;
    }

    @Override
    public Object execute(ClosureExpression it) {
        it.get(this);
        return this;
    }
}

@@ -598,11 +598,297 @@
 s;%0A    %7D
+%0A%0A    public %3CT%3E T get(String key, T def) %7B%0A        Object value = super.get(key);%0A        if (value == null)%0A            return def;%0A%0A        if (value instanceof Config && ((Config) value).isEmpty() && !(def instanceof Config))%0A            return def;%0A%0A        return (T) value;%0A    %7D
 %0A%7D%0A

add 'get or default'