@Test public void testDeepCopy() throws Exception { String configFileName = "yamlTestFile"; String resultFilePath = YamlTestUtils.RESULTS_DIR + configFileName + ".yml"; YamlUtilsTestHelper object = YamlUtilsTestHelper.newInstance( 1024, 3.14f, 3.14, true, "Yaml Test"); YamlUtils.toFile(object, resultFilePath); String resultYamlForDebug = CommonUtils.readFile(resultFilePath); System.out.println(new Date()); System.out.println(resultYamlForDebug); YamlUtilsTestHelper resultObjectFromFile = YamlUtils.toObject(resultFilePath, YamlUtilsTestHelper.class); Assert.assertTrue( String.format("%s: Test result and expect do not match!", configFileName), YamlUtils.deepEquals(object, resultObjectFromFile)); YamlUtilsTestHelper resultObjectFromBytes = YamlUtils.toObject(YamlUtils.toBytes(object), YamlUtilsTestHelper.class); Assert.assertTrue( YamlUtils.deepEquals(object, resultObjectFromBytes)); YamlUtilsTestHelper resultObjectFromDeepCopy = YamlUtils.deepCopy(object, YamlUtilsTestHelper.class); Assert.assertTrue( YamlUtils.deepEquals(object, resultObjectFromDeepCopy)); resultObjectFromDeepCopy.setNullField(""); Assert.assertFalse( YamlUtils.deepEquals(object, resultObjectFromDeepCopy)); resultObjectFromDeepCopy.setNullField(null); Assert.assertTrue( YamlUtils.deepEquals(object, resultObjectFromDeepCopy)); resultObjectFromDeepCopy.setIntegerField(null); Assert.assertFalse( YamlUtils.deepEquals(object, resultObjectFromDeepCopy)); resultObjectFromDeepCopy.setIntegerField(1024); Assert.assertTrue( YamlUtils.deepEquals(object, resultObjectFromDeepCopy)); }
public static <T> T deepCopy(T obj, Class<T> classRef) { return toObject(toBytes(obj), classRef); }
YamlUtils { public static <T> T deepCopy(T obj, Class<T> classRef) { return toObject(toBytes(obj), classRef); } }
YamlUtils { public static <T> T deepCopy(T obj, Class<T> classRef) { return toObject(toBytes(obj), classRef); }  }
YamlUtils { public static <T> T deepCopy(T obj, Class<T> classRef) { return toObject(toBytes(obj), classRef); }  static T toObject(byte[] bytes, Class<T> classRef); static T toObject(String fileName, Class<T> classRef); static byte[] toBytes(T obj); static void toFile(T obj, String fileName); static T deepCopy(T obj, Class<T> classRef); static Boolean deepEquals(T obj, T otherObj); static Boolean deepEquals(
      Map<TKey, TValue> yamlDict, Map<TKey, TValue> otherYamlDict); }
YamlUtils { public static <T> T deepCopy(T obj, Class<T> classRef) { return toObject(toBytes(obj), classRef); }  static T toObject(byte[] bytes, Class<T> classRef); static T toObject(String fileName, Class<T> classRef); static byte[] toBytes(T obj); static void toFile(T obj, String fileName); static T deepCopy(T obj, Class<T> classRef); static Boolean deepEquals(T obj, T otherObj); static Boolean deepEquals(
      Map<TKey, TValue> yamlDict, Map<TKey, TValue> otherYamlDict);  }