SingletonDataRestore { public void migrate(List<DataJsonNode> dataJsonNodes, R root) { DataJsonNode previousData = dataJsonNodes.stream().filter(dataJsonNode -> dataJsonNode.match(singletonPreviousDataClass)).findFirst().get(); V attributeValue = previousData.getAttributeValue(previousAttributeName, valueClass, simpleObjectMapper); setter.accept(root,attributeValue); } SingletonDataRestore(String singletonPreviousDataClass, String previousAttributeName, Class<V> valueClass, BiConsumer<R,V> setter, SimpleObjectMapper simpleObjectMapper); boolean canMigrate(DataStorageMetadataDictionary previousDataStorageMetadataDictionary); void migrate(List<DataJsonNode> dataJsonNodes, R root);  }
@Test public void test() { ExampleDataA exampleDataA = new ExampleDataA(); ExampleDataB value = new ExampleDataB(); value.stringAttribute.set("1234"); exampleDataA.referenceAttribute.set(value); String input = ObjectMapperBuilder.build().writeValueAsString(exampleDataA); input = input.replace( "stringAttribute", "oldStringAttribute"); System.out.println(input); SingletonDataRestore<ExampleDataA,String> singletonAttributeMove = new SingletonDataRestore<>("io.github.factoryfx.factory.merge.testdata.ExampleDataB","oldStringAttribute",String.class,(r, v)->{ r.referenceAttribute.get().stringAttribute.set(v); },ObjectMapperBuilder.build()); ExampleDataA exampleDataAMigrated = new ExampleDataA(); ExampleDataB valueMigrated = new ExampleDataB(); valueMigrated.stringAttribute.set(""); exampleDataAMigrated.referenceAttribute.set(valueMigrated); singletonAttributeMove.migrate(new DataJsonNode((ObjectNode) ObjectMapperBuilder.build().readTree(input)).collectChildrenFromRoot(),exampleDataAMigrated); Assertions.assertEquals("1234",exampleDataAMigrated.referenceAttribute.get().stringAttribute.get()); }