mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-09 17:34:50 +08:00
修复boolean无法对比问题
This commit is contained in:
@@ -240,17 +240,10 @@ public abstract class CompareUtils {
|
||||
}
|
||||
|
||||
public static boolean compare(Boolean bool, Object target) {
|
||||
if (bool.equals(target)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (bool && "true".equals(target)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return bool.equals(target) || String.valueOf(bool).equals(target);
|
||||
}
|
||||
|
||||
|
||||
public static boolean compare(Date date, Object target) {
|
||||
if (date == target) {
|
||||
return true;
|
||||
|
||||
@@ -15,13 +15,15 @@ public class DiffTest {
|
||||
Map<String, Object> before = new HashMap<>();
|
||||
before.put("name", "name");
|
||||
before.put("age",21);
|
||||
before.put("bool",true);
|
||||
before.put("bool", true);
|
||||
before.put("bool", false);
|
||||
before.put("birthday", DateFormatter.fromString("19910101"));
|
||||
|
||||
Map<String, Object> after = new HashMap<>();
|
||||
after.put("name", "name");
|
||||
after.put("age", "21");
|
||||
after.put("bool", "true");
|
||||
after.put("bool", "false");
|
||||
after.put("birthday", "1991-01-01");
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user