Skip to content

Commit

Permalink
fix boolean data type issue for Pojoutils.java#getDefaultValue
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongxiongzeng authored Nov 12, 2020
1 parent 4a265a5 commit b14e534
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ private static Object getDefaultValue(Class<?> parameterType) {
if ("char".equals(parameterType.getName())) {
return Character.MIN_VALUE;
}
if ("bool".equals(parameterType.getName())) {
if ("boolean".equals(parameterType.getName())) {
return false;
}
return parameterType.isPrimitive() ? 0 : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class SerializablePerson implements Serializable {

private String[] value = {"value1", "value2"};

public SerializablePerson(char description , boolean adult){

}
public String getName() {
return name;
}
Expand Down Expand Up @@ -94,4 +97,4 @@ public boolean equals(Object obj) {
return false;
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void test_primitive() throws Exception {
@Test
public void test_pojo() throws Exception {
assertObject(new Person());
assertObject(new SerializablePerson());
assertObject(new SerializablePerson(Character.MIN_VALUE, false));
}

@Test
Expand All @@ -147,7 +147,7 @@ public void test_Map_List_pojo() throws Exception {

List<Object> list = new ArrayList<Object>();
list.add(new Person());
list.add(new SerializablePerson());
list.add(new SerializablePerson(Character.MIN_VALUE, false));

map.put("k", list);

Expand Down Expand Up @@ -901,4 +901,4 @@ interface Message {

boolean isUrgent();
}
}
}

0 comments on commit b14e534

Please sign in to comment.