static Collection < String > toCollection ( String list ) { Collection < String > result = new ArrayList <> ( ) ; if ( list != null ) { String [ ] values = list . split ( "," ) ; for ( String value : values ) { String trimmed = value . trim ( ) ; if ( ! trimmed . isEmpty ( ) ) { result . add ( trimmed ) ; } } } return result ; }
Return the provided comma - separated String as a collection . Order is maintained .