private static Map < String , String > parseKeyValueMap ( String kvString , Function < String , String > valueMapper ) { return Stream . of ( Optional . ofNullable ( kvString ) . map ( StringUtils :: trimAllWhitespace ) . filter ( StringUtils :: hasText ) . map ( s -> s . split ( PAIR_SEPARATOR ) ) . orElse ( new String [ 0 ] ) ) . map ( StringUtils :: trimAllWhitespace ) . map ( pair -> pair . split ( KEY_VALUE_SEPARATOR , 2 ) ) . collect ( toMap ( FIRST . andThen ( StringUtils :: trimAllWhitespace ) , SECOND . andThen ( StringUtils :: trimAllWhitespace ) . andThen ( valueMapper ) ) ) ; }
Parses a key - value pair string such as param1 = WdfaA param2 = AZrr param3 into a map .