@Test public void isFieldEquals() { Field field0 = new Field("name", 0, "111"); Field field1 = new Field("name", 1, "111"); Field field2 = new Field("name", 0, "222"); Field field3 = new Field("age", 0, "222"); Field field4 = new Field("name", 0, null); Assertions.assertFalse(DataCompareUtils.isFieldEquals(field0, null).getResult()); Assertions.assertFalse(DataCompareUtils.isFieldEquals(null, field0).getResult()); Assertions.assertFalse(DataCompareUtils.isFieldEquals(field0, field1).getResult()); Assertions.assertFalse(DataCompareUtils.isFieldEquals(field0, field2).getResult()); Assertions.assertFalse(DataCompareUtils.isFieldEquals(field0, field3).getResult()); Assertions.assertFalse(DataCompareUtils.isFieldEquals(field0, field4).getResult()); Field field10 = new Field("Name", 0, "111"); Field field11 = new Field("Name", 0, null); Assertions.assertTrue(DataCompareUtils.isFieldEquals(field0, field10).getResult()); Assertions.assertTrue(DataCompareUtils.isFieldEquals(field4, field11).getResult()); Field field12 = new Field("information", JDBCType.BLOB.getVendorTypeNumber(), new String("hello world").getBytes()); Field field13 = new Field("information", JDBCType.BLOB.getVendorTypeNumber(), new String("hello world").getBytes()); Assertions.assertTrue(DataCompareUtils.isFieldEquals(field12, field13).getResult()); }
public static Result<Boolean> isFieldEquals(Field f0, Field f1) { if (f0 == null) { return Result.build(f1 == null); } else { if (f1 == null) { return Result.build(false); } else { if (StringUtils.equalsIgnoreCase(f0.getName(), f1.getName()) && f0.getType() == f1.getType()) { if (f0.getValue() == null) { return Result.build(f1.getValue() == null); } else { if (f1.getValue() == null) { return Result.buildWithParams(false, "Field not equals, name {}, new value is null", f0.getName()); } else { String currentSerializer = AbstractUndoLogManager.getCurrentSerializer(); if (StringUtils.equals(currentSerializer, FastjsonUndoLogParser.NAME)) { convertType(f0, f1); } boolean result = Objects.deepEquals(f0.getValue(), f1.getValue()); if (result) { return Result.ok(); } else { return Result.buildWithParams(false, "Field not equals, name {}, old value {}, new value {}", f0.getName(), f0.getValue(), f1.getValue()); } } } } else { return Result.buildWithParams(false, "Field not equals, old name {} type {}, new name {} type {}", f0.getName(), f0.getType(), f1.getName(), f1.getType()); } } } }
DataCompareUtils { public static Result<Boolean> isFieldEquals(Field f0, Field f1) { if (f0 == null) { return Result.build(f1 == null); } else { if (f1 == null) { return Result.build(false); } else { if (StringUtils.equalsIgnoreCase(f0.getName(), f1.getName()) && f0.getType() == f1.getType()) { if (f0.getValue() == null) { return Result.build(f1.getValue() == null); } else { if (f1.getValue() == null) { return Result.buildWithParams(false, "Field not equals, name {}, new value is null", f0.getName()); } else { String currentSerializer = AbstractUndoLogManager.getCurrentSerializer(); if (StringUtils.equals(currentSerializer, FastjsonUndoLogParser.NAME)) { convertType(f0, f1); } boolean result = Objects.deepEquals(f0.getValue(), f1.getValue()); if (result) { return Result.ok(); } else { return Result.buildWithParams(false, "Field not equals, name {}, old value {}, new value {}", f0.getName(), f0.getValue(), f1.getValue()); } } } } else { return Result.buildWithParams(false, "Field not equals, old name {} type {}, new name {} type {}", f0.getName(), f0.getType(), f1.getName(), f1.getType()); } } } } }
DataCompareUtils { public static Result<Boolean> isFieldEquals(Field f0, Field f1) { if (f0 == null) { return Result.build(f1 == null); } else { if (f1 == null) { return Result.build(false); } else { if (StringUtils.equalsIgnoreCase(f0.getName(), f1.getName()) && f0.getType() == f1.getType()) { if (f0.getValue() == null) { return Result.build(f1.getValue() == null); } else { if (f1.getValue() == null) { return Result.buildWithParams(false, "Field not equals, name {}, new value is null", f0.getName()); } else { String currentSerializer = AbstractUndoLogManager.getCurrentSerializer(); if (StringUtils.equals(currentSerializer, FastjsonUndoLogParser.NAME)) { convertType(f0, f1); } boolean result = Objects.deepEquals(f0.getValue(), f1.getValue()); if (result) { return Result.ok(); } else { return Result.buildWithParams(false, "Field not equals, name {}, old value {}, new value {}", f0.getName(), f0.getValue(), f1.getValue()); } } } } else { return Result.buildWithParams(false, "Field not equals, old name {} type {}, new name {} type {}", f0.getName(), f0.getType(), f1.getName(), f1.getType()); } } } }  }
DataCompareUtils { public static Result<Boolean> isFieldEquals(Field f0, Field f1) { if (f0 == null) { return Result.build(f1 == null); } else { if (f1 == null) { return Result.build(false); } else { if (StringUtils.equalsIgnoreCase(f0.getName(), f1.getName()) && f0.getType() == f1.getType()) { if (f0.getValue() == null) { return Result.build(f1.getValue() == null); } else { if (f1.getValue() == null) { return Result.buildWithParams(false, "Field not equals, name {}, new value is null", f0.getName()); } else { String currentSerializer = AbstractUndoLogManager.getCurrentSerializer(); if (StringUtils.equals(currentSerializer, FastjsonUndoLogParser.NAME)) { convertType(f0, f1); } boolean result = Objects.deepEquals(f0.getValue(), f1.getValue()); if (result) { return Result.ok(); } else { return Result.buildWithParams(false, "Field not equals, name {}, old value {}, new value {}", f0.getName(), f0.getValue(), f1.getValue()); } } } } else { return Result.buildWithParams(false, "Field not equals, old name {} type {}, new name {} type {}", f0.getName(), f0.getType(), f1.getName(), f1.getType()); } } } }  static Result<Boolean> isFieldEquals(Field f0, Field f1); static Result<Boolean> isRecordsEquals(TableRecords beforeImage, TableRecords afterImage); static Result<Boolean> isRowsEquals(TableMeta tableMetaData, List<Row> oldRows, List<Row> newRows); }
DataCompareUtils { public static Result<Boolean> isFieldEquals(Field f0, Field f1) { if (f0 == null) { return Result.build(f1 == null); } else { if (f1 == null) { return Result.build(false); } else { if (StringUtils.equalsIgnoreCase(f0.getName(), f1.getName()) && f0.getType() == f1.getType()) { if (f0.getValue() == null) { return Result.build(f1.getValue() == null); } else { if (f1.getValue() == null) { return Result.buildWithParams(false, "Field not equals, name {}, new value is null", f0.getName()); } else { String currentSerializer = AbstractUndoLogManager.getCurrentSerializer(); if (StringUtils.equals(currentSerializer, FastjsonUndoLogParser.NAME)) { convertType(f0, f1); } boolean result = Objects.deepEquals(f0.getValue(), f1.getValue()); if (result) { return Result.ok(); } else { return Result.buildWithParams(false, "Field not equals, name {}, old value {}, new value {}", f0.getName(), f0.getValue(), f1.getValue()); } } } } else { return Result.buildWithParams(false, "Field not equals, old name {} type {}, new name {} type {}", f0.getName(), f0.getType(), f1.getName(), f1.getType()); } } } }  static Result<Boolean> isFieldEquals(Field f0, Field f1); static Result<Boolean> isRecordsEquals(TableRecords beforeImage, TableRecords afterImage); static Result<Boolean> isRowsEquals(TableMeta tableMetaData, List<Row> oldRows, List<Row> newRows);  }