use of de.danielbechler.diff.identity.IdentityStrategy in project winery by eclipse.
the class VersionSupport method calculateDifferences.
public static <T extends TExtensibleElements> ToscaDiff calculateDifferences(T oldVersion, T newVersion) {
IdentityStrategy identityStrategy = (o, o1) -> {
if (o instanceof HasIdInIdOrNameField && o1 instanceof HasIdInIdOrNameField) {
return Objects.equals(((HasIdInIdOrNameField) o).getIdFromIdOrNameField(), ((HasIdInIdOrNameField) o1).getIdFromIdOrNameField());
} else {
return Objects.equals(o, o1);
}
};
DiffNode diffNode = ObjectDifferBuilder.startBuilding().categories().ofType(TRelationshipTemplate.SourceOrTargetElement.class).toBe(REFERENCING_OBJECT).and().inclusion().exclude().propertyName("nodeTemplateOrRelationshipTemplate").propertyName("fakeJacksonType").propertyName("any").propertyName("internalAny").propertyName("prefix").propertyName("elementName").propertyName("namespace").category(REFERENCING_OBJECT).and().identity().setDefaultCollectionItemIdentityStrategy(identityStrategy).and().build().compare(newVersion, oldVersion);
return ToscaDiff.convertDiffToToscaDiff(diffNode, oldVersion, newVersion);
}
Aggregations