/* * Decompiled with CFR 0.152. */ package com.script; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; public class SimpleBindings implements Bindings { private Map map; public SimpleBindings(Map m) { if (m == null) { throw new NullPointerException(); } this.map = m; } public SimpleBindings() { this(new HashMap()); } @Override public Object put(String name, Object value) { this.checkKey(name); return this.map.put(name, value); } @Override public void putAll(Map toMerge) { if (toMerge == null) { throw new NullPointerException("toMerge map is null"); } for (Map.Entry entry : toMerge.entrySet()) { String key = entry.getKey(); this.checkKey(key); this.put(key, entry.getValue()); } } @Override public void clear() { this.map.clear(); } @Override public boolean containsKey(Object key) { this.checkKey(key); return this.map.containsKey(key); } @Override public boolean containsValue(Object value) { return this.map.containsValue(value); } @Override public Set> entrySet() { return this.map.entrySet(); } @Override public Object get(Object key) { this.checkKey(key); return this.map.get(key); } @Override public boolean isEmpty() { return this.map.isEmpty(); } @Override public Set keySet() { return this.map.keySet(); } @Override public Object remove(Object key) { this.checkKey(key); return this.map.remove(key); } @Override public int size() { return this.map.size(); } @Override public Collection values() { return this.map.values(); } private void checkKey(Object key) { if (key == null) { throw new NullPointerException("key can not be null"); } if (!(key instanceof String)) { throw new ClassCastException("key should be a String"); } if (key.equals("")) { throw new IllegalArgumentException("key can not be empty"); } } }