[logseq-plugin-git:commit] 2023-08-11T09:14:35.822Z
This commit is contained in:
parent
d2ee60a5c0
commit
adf05361b9
@ -1,2 +1,14 @@
|
||||
-
|
||||
-
|
||||
- String key value to map [[Code Snippet]] [[Java]]
|
||||
- ``` java
|
||||
private MultiValueMap<String, String> params(final String... params) {
|
||||
if (params.length % 2 != 0) {
|
||||
throw new IllegalArgumentException("The params need to be as key value pair");
|
||||
}
|
||||
final LinkedMultiValueMap<String, String> result = new LinkedMultiValueMap<>();
|
||||
IntStream.range(0, params.length / 2)
|
||||
.map(i -> i * 2)
|
||||
.mapToObj(i -> new ImmutablePair<>(params[i], params[i + 1]))
|
||||
.forEach(p -> result.add(p.getLeft(), p.getRight()));
|
||||
return result;
|
||||
}
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user