
com.qdesrame.openapi.diff.model.ListDiff Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-diff Show documentation
Show all versions of openapi-diff Show documentation
Utility for comparing two OpenAPI specifications.
package com.qdesrame.openapi.diff.model;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@Getter
public class ListDiff {
private List increased;
private List missing;
private List sharedItem;
private ListDiff() {
this.sharedItem = new ArrayList<>();
this.increased = new ArrayList<>();
this.missing = new ArrayList<>();
}
public static ListDiff diff(List left, List right) {
ListDiff instance = new ListDiff<>();
if (left == null && right == null) {
return instance;
}
if (left == null) {
instance.increased = right;
return instance;
}
if (right == null) {
instance.missing = left;
return instance;
}
instance.increased = new ArrayList<>(right);
instance.missing = new ArrayList<>();
for (T leftItem : left) {
if (right.contains(leftItem)) {
instance.increased.remove(leftItem);
instance.sharedItem.add(leftItem);
} else {
instance.missing.add(leftItem);
}
}
return instance;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy