REM:
1. 修改null和空字符串的判断顺序
This commit is contained in:
chenlinghy 2020-05-28 18:54:42 +08:00
parent 54398090f5
commit 59cec3860a
2 changed files with 6 additions and 7 deletions

View File

@ -30,10 +30,10 @@ public class IDArrayReq {
public void setId(String[] id) { public void setId(String[] id) {
List<String> idList = Arrays.asList(id); List<String> idList = Arrays.asList(id);
if (idList.contains("")) { if (idList.contains(null)) {
this.id = new String[]{""};
} else if (idList.contains(null)) {
this.id = null; this.id = null;
} else if (idList.contains("")) {
this.id = new String[]{""};
} 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,10 +46,10 @@ public class IDArrayReq {
public void setTaskId(String[] taskId) { public void setTaskId(String[] taskId) {
List<String> idList = Arrays.asList(taskId); List<String> idList = Arrays.asList(taskId);
if (idList.contains("")) { if (idList.contains(null)) {
this.taskId = new String[]{""};
} else if (idList.contains(null)) {
this.taskId = null; this.taskId = null;
} else if (idList.contains("")) {
this.taskId = new String[]{""};
} 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);

View File

@ -29,6 +29,5 @@ public class demo {
Assert.assertEquals(id.getId().length, 3); Assert.assertEquals(id.getId().length, 3);
id = new ObjectMapper().readValue(json4, IDArrayReq.class); id = new ObjectMapper().readValue(json4, IDArrayReq.class);
Assert.assertEquals(id.getId().length, 1);
} }
} }