@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Object applyValueToMap(Object value, Map target) { if (value instanceof StructuredModification) { return ((StructuredModification)value).applyToKeyInMap(this, target); } else if (value instanceof Collection) { String warning = "Discouraged undecorated setting of a collection to ListConfigKey "+this+": use ListModification.{set,add}. " + "Defaulting to 'add'. Look at debug logging for call stack."; log.warn(warning); if (log.isDebugEnabled()) log.debug("Trace for: "+warning, new Throwable("Trace for: "+warning)); for (Object v: (Collection)value) applyValueToMap(v, target); return null; } else { // just add to list, using anonymous key target.put(subKey(), value); return null; } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Object applyValueToMap(Object value, Map target) { if (value instanceof StructuredModification) { return ((StructuredModification)value).applyToKeyInMap(this, target); } else if (value instanceof Collection) { String warning = "Discouraged undecorated setting of a collection to SetConfigKey "+this+": use SetModification.{set,add}. " + "Defaulting to 'add'. Look at debug logging for call stack."; log.warn(warning); if (log.isDebugEnabled()) log.debug("Trace for: "+warning, new Throwable("Trace for: "+warning)); for (Object v: (Collection)value) applyValueToMap(v, target); return null; } else if (value instanceof TaskAdaptable) { String warning = "Discouraged undecorated setting of a task to SetConfigKey "+this+": use SetModification.{set,add}. " + "Defaulting to 'add'. Look at debug logging for call stack."; log.warn(warning); // just add to set, using anonymous key target.put(subKey(), value); return null; } else { // just add to set, using anonymous key target.put(subKey(), value); return null; } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Object applyValueToMap(Object value, Map target) { if (value == null) return null; if (value instanceof StructuredModification) return ((StructuredModification)value).applyToKeyInMap(this, target); if (value instanceof Map.Entry) return applyEntryValueToMap((Map.Entry)value, target); if (!(value instanceof Map)) throw new IllegalArgumentException("Cannot set non-map entries "+value+" on "+this); Map result = new MutableMap(); for (Object entry: ((Map)value).entrySet()) { Map.Entry entryT = (Map.Entry)entry; result.put(entryT.getKey(), applyEntryValueToMap(entryT, target)); } return result; }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Object applyToKeyInMap(SetConfigKey<T> key, Map target) { if (clearFirst) { StructuredModification<StructuredConfigKey> clearing = StructuredModifications.clearing(); clearing.applyToKeyInMap(key, target); } for (T o: this) target.put(key.subKey(), o); return null; } }
@SuppressWarnings({ "rawtypes" }) @Override public Object applyToKeyInMap(MapConfigKey<V> key, Map target) { if (clearFirst) { StructuredModification<StructuredConfigKey> clearing = StructuredModifications.clearing(); clearing.applyToKeyInMap(key, target); } return key.applyValueToMap(new LinkedHashMap<String,V>(this), target); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Object applyToKeyInMap(ListConfigKey<T> key, Map target) { if (clearFirst) { StructuredModification<StructuredConfigKey> clearing = StructuredModifications.clearing(); clearing.applyToKeyInMap(key, target); } for (T o: this) target.put(key.subKey(), o); return null; } }