parent
560944c98b
commit
54398090f5
|
@ -32,6 +32,8 @@ public class IDArrayReq {
|
||||||
|
|
||||||
if (idList.contains("")) {
|
if (idList.contains("")) {
|
||||||
this.id = new String[]{""};
|
this.id = new String[]{""};
|
||||||
|
} else if (idList.contains(null)) {
|
||||||
|
this.id = null;
|
||||||
} else {
|
} else {
|
||||||
Map<String, Long> ret = idList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
Map<String, Long> ret = idList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
||||||
System.out.println(ret);
|
System.out.println(ret);
|
||||||
|
@ -46,6 +48,8 @@ public class IDArrayReq {
|
||||||
|
|
||||||
if (idList.contains("")) {
|
if (idList.contains("")) {
|
||||||
this.taskId = new String[]{""};
|
this.taskId = new String[]{""};
|
||||||
|
} else if (idList.contains(null)) {
|
||||||
|
this.taskId = null;
|
||||||
} else {
|
} else {
|
||||||
Map<String, Long> ret = idList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
Map<String, Long> ret = idList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
||||||
System.out.println(ret);
|
System.out.println(ret);
|
||||||
|
|
|
@ -16,13 +16,19 @@ public class demo {
|
||||||
String json = "{\"id\":[\"1\", \"123\", \"1234\", \"1234\"]}";
|
String json = "{\"id\":[\"1\", \"123\", \"1234\", \"1234\"]}";
|
||||||
String json2 = "{\"id\":[\"1\", \"123\", \"1234\"]}";
|
String json2 = "{\"id\":[\"1\", \"123\", \"1234\"]}";
|
||||||
String json3 = "{\"id\":[\"\", \"1\", \"123\", \"1234\"]}";
|
String json3 = "{\"id\":[\"\", \"1\", \"123\", \"1234\"]}";
|
||||||
|
String json4 = "{\"id\":[\"1\", \"123\", \"1234\", null]}";
|
||||||
|
|
||||||
|
|
||||||
IDArrayReq id = new ObjectMapper().readValue(json3, IDArrayReq.class);
|
IDArrayReq id = new ObjectMapper().readValue(json3, IDArrayReq.class);
|
||||||
Assert.assertEquals(id.getId().length, 1);
|
Assert.assertEquals(id.getId().length, 1);
|
||||||
|
|
||||||
id = new ObjectMapper().readValue(json2, IDArrayReq.class);
|
id = new ObjectMapper().readValue(json2, IDArrayReq.class);
|
||||||
Assert.assertEquals(id.getId().length, 3);
|
Assert.assertEquals(id.getId().length, 3);
|
||||||
|
|
||||||
id = new ObjectMapper().readValue(json, IDArrayReq.class);
|
id = new ObjectMapper().readValue(json, IDArrayReq.class);
|
||||||
Assert.assertEquals(id.getId().length, 3);
|
Assert.assertEquals(id.getId().length, 3);
|
||||||
|
|
||||||
|
id = new ObjectMapper().readValue(json4, IDArrayReq.class);
|
||||||
|
Assert.assertEquals(id.getId().length, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue