All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.zenwave360.zdl.antlr.FluentMap Maven / Gradle / Ivy

The newest version!
package io.github.zenwave360.zdl.antlr;

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

class FluentMap extends LinkedHashMap {

    public FluentMap with(String key, Object value) {
        put(key, value);
        return this;
    }

    public FluentMap appendTo(String collection, String key, Object value) {
        if(!containsKey(collection)) {
            put(collection, new FluentMap());
        }
        ((Map) get(collection)).put(key, value);
        return this;
    }

    public FluentMap appendTo(String collection, Map value) {
        if(!containsKey(collection)) {
            put(collection, new FluentMap());
        }
        ((Map) get(collection)).putAll(value);
        return this;
    }

    public FluentMap appendToList(String collection, Object value) {
        if(!containsKey(collection)) {
            put(collection, new ArrayList());
        }
        ((List) get(collection)).add(value);
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy