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