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;
/**
* 基于Map
的TemplateContext
实现。
*
*/
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();
}
}