#15 Ability to copy Map to Map

closed
None
5
2005-12-09
2005-12-02
No

Why can't we do this? :)

Discussion

  • Franz Garsombke

    Franz Garsombke - 2005-12-03
    • status: open --> pending
     
  • Franz Garsombke

    Franz Garsombke - 2005-12-03

    Logged In: YES
    user_id=550744

    Ok...I guess we already support this. I have been staring at
    this code for too long. I will just document it...

    private Object mapMap(Object sourceMapValue, ClassMap
    classMap, FieldMap fieldMap, Object destObj)
    throws IllegalAccessException, InstantiationException,
    InvocationTargetException {
    Map result = null;

    Object field = doesFieldExist(fieldMap, destObj);
    result = (Map) sourceMapValue.getClass().newInstance();
    if (field == null) {
    // do nothing
    } else {
    result.putAll(((Map) sourceMapValue));
    }

    Map sourceMap = (Map) sourceMapValue;
    Set sourceEntrySet = sourceMap.entrySet();
    Iterator iter = sourceEntrySet.iterator();
    while (iter.hasNext()) {
    Map.Entry sourceEntry = (Map.Entry) iter.next();
    Object sourceEntryValue = sourceEntry.getValue();
    Object destEntryValue =
    mapOrRecurseObject(sourceEntryValue,
    sourceEntryValue.getClass(), classMap, fieldMap,
    destObj);
    result.put(sourceEntry.getKey(), destEntryValue);
    }
    return result;
    }

     
  • Franz Garsombke

    Franz Garsombke - 2005-12-09
    • status: pending --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks