if (s == null) { s = new ChainedMap(getRootMap()); p = new ChainedMap(s); p.put(targetedProperty, value);
/** * @return true if the child map contains this key OR the parent map is not null and contains this key. * <pre>child.containsKey(key) || (parent != null && parent.containsKey(key));</pre> */ public boolean containsKey(Object key) { if (key == null) throw new NullPointerException("Null keys forbidden!"); return child.containsKey(key) || (parent != null && parent.containsKey(key)); }
/** * @return true if the child map contains this value OR the parent is not null * <pre>child.containsValue(value) || (parent != null && parent.containsValue(value));</pre> */ public boolean containsValue(Object value) { return child.containsValue(value) || (parent != null && parent.containsValue(value)); }
public String getProperty(String property) { return (String) getRootMap().get(property); }
public int size() { return keySet().size(); }
/** * @return a new set instance merging all keys contained in the child and parent maps. <strong>The returned set is not backed by the maps.</strong> * Any references to the returned sets are hold at the holder's own risks. This breaks the general {@link java.util.Map#entrySet()} contract. */ public Set keySet() { HashSet s = new HashSet(child.keySet()); if (parent != null) s.addAll(parent.keySet()); return s; } }
/** * @return true if the child map is empty AND the parent map is null or empty as well. * <pre>child.isEmpty() && (parent == null || parent.isEmpty());</pre> */ public boolean isEmpty() { return child.isEmpty() && (parent == null || parent.isEmpty()); }
/** * Put these pairs in the child map. */ public void putAll(Map t) { for (Object e : t.entrySet()) { put(((Map.Entry) e).getKey(), ((Map.Entry) e).getValue()); } }
/** * Perform a look up for the given key on the child map, and if not found then perform the look up on the parent map. * * @param key * @return */ public Object get(Object key) { Object lv = getLocally(key); if (lv != null) return lv; else if (parent != null) return parent.get(key); return null; }
private ChainedMap initRoot() { ChainedMap root = new ChainedMap(); hierarchicalMap.put(null, null, root); return root; }