private void storeList ( Properties props , Map < String , List < String > > details , String field ) { Set < String > valueSet = new LinkedHashSet < String > ( ) ; // merge with original property value if exists String currentValue = props . getProperty ( field , "" ) ; if ( ! "" . equals ( currentValue ) ) { String [ ] currentList = currentValue . split ( "," ) ; valueSet . addAll ( Arrays . asList ( currentList ) ) ; } valueSet . addAll ( details . get ( field ) ) ; String joinedList = StringUtils . join ( valueSet , "," ) ; props . setProperty ( field , joinedList ) ; }
Take a list of strings from a Java Map concatenate the values together and store them in a Properties object using the Map s original key .