public void putAll(Map<? extends K, ? extends V> m) { for (Entry<? extends K, ? extends V> entry : m.entrySet()) { put(entry.getKey(), entry.getValue()); } }
/** * Sets the node meta data but allows overwriting values. * * @param key - the meta data key * @param value - the meta data value * @return the old node meta data value for this key * @throws GroovyBugError if key is null */ public Object putNodeMetaData(Object key, Object value) { if (key == null) throw new GroovyBugError("Tried to set meta data with null key on " + this + "."); if (metaDataMap == null) { metaDataMap = new ListHashMap(); } return metaDataMap.put(key, value); }
/** * Sets the node meta data but allows overwriting values. * * @param key - the meta data key * @param value - the meta data value * @return the old node meta data value for this key * @throws GroovyBugError if key is null */ public Object putNodeMetaData(Object key, Object value) { if (key == null) throw new GroovyBugError("Tried to set meta data with null key on " + this + "."); if (metaDataMap == null) { metaDataMap = new ListHashMap(); } return metaDataMap.put(key, value); }
/** * Sets the node meta data. * * @param key - the meta data key * @param value - the meta data value * @throws GroovyBugError if key is null or there is already meta * data under that key */ public void setNodeMetaData(Object key, Object value) { if (key==null) throw new GroovyBugError("Tried to set meta data with null key on "+this+"."); if (metaDataMap == null) { metaDataMap = new ListHashMap(); } Object old = metaDataMap.put(key,value); if (old!=null) throw new GroovyBugError("Tried to overwrite existing meta data "+this+"."); }
/** * Sets the node meta data for the provided key. * * @param key - the meta data key * @param value - the meta data value * @throws GroovyBugError if key is null or there is already meta * data under that key */ public void setNodeMetaData(Object key, Object value) { if (key==null) throw new GroovyBugError("Tried to set meta data with null key on "+this+"."); if (metaDataMap == null) { metaDataMap = new ListHashMap(); } Object old = metaDataMap.put(key,value); if (old!=null) throw new GroovyBugError("Tried to overwrite existing meta data "+this+"."); }
protected void saveVariableExpressionMetadata(final Set<VariableExpression> closureSharedExpressions, final Map<VariableExpression, ListHashMap> typesBeforeVisit) { for (VariableExpression ve : closureSharedExpressions) { // GROOVY-6921: We must force a call to getType in order to update closure shared variable whose // types are inferred thanks to closure parameter type inference getType(ve); ListHashMap<StaticTypesMarker, Object> metadata = new ListHashMap<StaticTypesMarker, Object>(); for (StaticTypesMarker marker : StaticTypesMarker.values()) { Object value = ve.getNodeMetaData(marker); if (value != null) { metadata.put(marker, value); } } typesBeforeVisit.put(ve, metadata); Variable accessedVariable = ve.getAccessedVariable(); if (accessedVariable != ve && accessedVariable instanceof VariableExpression) { saveVariableExpressionMetadata(Collections.singleton((VariableExpression) accessedVariable), typesBeforeVisit); } } }
/** * Sets the node meta data but allows overwriting values. * * @param key - the meta data key * @param value - the meta data value * @return the old node meta data value for this key * @throws GroovyBugError if key is null */ public Object putNodeMetaData(Object key, Object value) { if (key == null) throw new GroovyBugError("Tried to set meta data with null key on " + this + "."); return metaDataMap.put(key, value); }
/** * Sets the node meta data. * * @param key - the meta data key * @param value - the meta data value * @throws GroovyBugError if key is null or there is already meta * data under that key */ public void setNodeMetaData(Object key, Object value) { if (key==null) throw new GroovyBugError("Tried to set meta data with null key on "+this+"."); Object old = metaDataMap.put(key,value); if (old!=null) throw new GroovyBugError("Tried to overwrite existing meta data "+this+"."); }