public static void addToList(Map<String, Object> flds, String fldName, Object fldValue) {
    """
	Utility routine to keep list of objects small.
	add fldValue to the fldName list in flds.
	fldValue may be a list or an object.
	if no list, just keep the object without creating a list (common case).
	otherwise add it to the existing list.
    """
    if (fldValue == null) return;
    Object prevVal = flds.get(fldName);
    if (prevVal == null) {
      flds.put(fldName, fldValue);
      return;
    }

    List prevList;
    if (prevVal instanceof List) {
      prevList = (List) prevVal;
    } else {
      prevList = new ArrayList(5);
      prevList.add(prevVal);
      flds.put(fldName, prevList);
    }

    if (fldValue instanceof List) {
      prevList.addAll((List) fldValue);
    } else {
      prevList.add(fldValue);
    }
  }
public static void addToList(Map<String, Object> flds, String fldName, Object fldValue) {
    if (fldValue == null) return;
    Object prevVal = flds.get(fldName);
    if (prevVal == null) {
      flds.put(fldName, fldValue);
      return;
    }

    List prevList;
    if (prevVal instanceof List) {
      prevList = (List) prevVal;
    } else {
      prevList = new ArrayList(5);
      prevList.add(prevVal);
      flds.put(fldName, prevList);
    }

    if (fldValue instanceof List) {
      prevList.addAll((List) fldValue);
    } else {
      prevList.add(fldValue);
    }
  }
public static void addToList ( Map < String , Object > flds , String fldName , Object fldValue ) { if ( fldValue == null ) return ; Object prevVal = flds . get ( fldName ) ; if ( prevVal == null ) { flds . put ( fldName , fldValue ) ; return ; } List prevList ; if ( prevVal instanceof List ) { prevList = ( List ) prevVal ; } else { prevList = new ArrayList ( 5 ) ; prevList . add ( prevVal ) ; flds . put ( fldName , prevList ) ; } if ( fldValue instanceof List ) { prevList . addAll ( ( List ) fldValue ) ; } else { prevList . add ( fldValue ) ; } }
Utility routine to keep list of objects small.
add fldValue to the fldName list in flds.
fldValue may be a list or an object.
if no list, just keep the object without creating a list (common case).
otherwise add it to the existing list.
Utility routine to keep list of objects small . add fldValue to the fldName list in flds . fldValue may be a list or an object . if no list just keep the object without creating a list ( common case ) . otherwise add it to the existing list .