mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
testdata for IDEA-127124
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
enum TestEnum {EnumOne, EnumTwo, EnumThree}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String testString = "EnumOne=0, EnumTwo=2,EnumThree=1";
|
||||
|
||||
Map<TestEnum, Integer> enumMap = Optional.ofNullable(testString)
|
||||
.map(levelsString -> Arrays.stream(levelsString.split("\\s*,\\s*"))
|
||||
.map(splitStringComponent -> splitStringComponent.split("="))
|
||||
.filter(keyValArray -> keyValArray.length == 2)
|
||||
.collect(Collectors.toMap(keyValArray -> TestEnum.valueOf(keyValArray[0]), s -> Integer.valueOf(s[1]))))
|
||||
.orElse(new HashMap<>());
|
||||
|
||||
System.out.println(enumMap);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user