Skip to content

Commit

Permalink
more option method on ActionInput
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Mar 17, 2024
1 parent 6ca3fde commit b4ec0e8
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,29 @@ default List<String> getOptionAsList() {

/**
* Get the option as a map.
* The format is {@code key=value,key=value}
* The map format is {@code key=value}
*
* @param separator the separator
*
* @return the map
*
* @see #getOptionStream(String)
*/
default Map<String, String> getOptionAsMap() {
return getOptionStream()
default Map<String, String> getOptionAsMap(String separator) {
return getOptionStream(separator)
.map(s -> s.split("="))
.collect(Collectors.toMap(strings -> strings[0].trim(), strings -> strings.length > 1 ? strings[1].trim() : ""));
}

/**
* Get the option as a map.
* The format is {@code key=value,key=value}
*
* @return the map
*
* @see #getOptionAsMap()
*/
default Map<String, String> getOptionAsMap() {
return getOptionAsMap(",");
}
}

0 comments on commit b4ec0e8

Please sign in to comment.