public static void addImportStylePatterns ( Map < String , Object > patterns , String str ) { if ( str == null || "" . equals ( str . trim ( ) ) ) { return ; } String [ ] items = str . split ( " " ) ; for ( String item : items ) { String qualifiedNamespace = item . substring ( 0 , item . lastIndexOf ( ' ' ) ) . trim ( ) ; String name = item . substring ( item . lastIndexOf ( ' ' ) + 1 ) . trim ( ) ; Object object = patterns . get ( qualifiedNamespace ) ; if ( object == null ) { if ( STAR . equals ( name ) ) { patterns . put ( qualifiedNamespace , STAR ) ; } else { // create a new list and add it List < String > list = new ArrayList < String > ( ) ; list . add ( name ) ; patterns . put ( qualifiedNamespace , list ) ; } } else if ( name . equals ( STAR ) ) { // if its a STAR now add it anyway, we don't care if it was a STAR or a List before patterns . put ( qualifiedNamespace , STAR ) ; } else { // its a list so add it if it doesn't already exist List list = ( List ) object ; if ( ! list . contains ( name ) ) { list . add ( name ) ; } } } }
Populates the import style pattern map from give comma delimited string