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

org.zodiac.template.base.support.MappedTemplateContext Maven / Gradle / Ivy

The newest version!
package org.zodiac.template.base.support;

import java.util.Map;
import java.util.Set;

import org.zodiac.sdk.toolkit.util.AssertUtil;
import org.zodiac.sdk.toolkit.util.ToStringBuilder;
import org.zodiac.sdk.toolkit.util.collection.CollUtil;
import org.zodiac.template.base.TemplateContext;

/**
 * 基于MapTemplateContext实现。
 *
 */
public class MappedTemplateContext implements TemplateContext {

    private final Map map;

    public MappedTemplateContext() {
        this.map = CollUtil.map();
    }

    public MappedTemplateContext(Map map) {
        this.map = AssertUtil.assertNotNull(map, "map");
    }

    public Map getMap() {
        return map;
    }

    public boolean containsKey(String key) {
        return map.containsKey(key);
    }

    public Object get(String key) {
        return map.get(key);
    }

    public void put(String key, Object value) {
        map.put(key, value);
    }

    public Set keySet() {
        return map.keySet();
    }

    public void remove(String key) {
        map.remove(key);
    }

    @Override
    public String toString() {
        return new ToStringBuilder().append(getClass().getSimpleName()).appendMap(map, true).toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy