You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/06/14 15:29:55 UTC
[sling-whiteboard] 02/03: [feature-diff] diff method args moved to
data object in order to simplify readability and backward compatibility as
suggested by @bosschaert
This is an automated email from the ASF dual-hosted git repository.
simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit 8333342021e93b8990520d50b2a02b20a25dd7be
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Fri Jun 14 16:41:46 2019 +0200
[feature-diff] diff method args moved to data object in order to
simplify readability and backward compatibility as suggested by
@bosschaert
---
.../sling/feature/diff/ArtifactsComparator.java | 5 +++++
.../feature/diff/ConfigurationsComparator.java | 5 +++++
.../sling/feature/diff/ExtensionsComparator.java | 5 +++++
.../org/apache/sling/feature/diff/FeatureDiff.java | 23 +++++++++++-----------
.../diff/FrameworkPropertiesComparator.java | 5 +++++
5 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/ArtifactsComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/ArtifactsComparator.java
index a2935db..2a3e521 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/ArtifactsComparator.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/ArtifactsComparator.java
@@ -24,6 +24,11 @@ import org.apache.sling.feature.diff.spi.FeatureElementComparator;
final class ArtifactsComparator implements FeatureElementComparator {
@Override
+ public String getId() {
+ return "artifacts";
+ }
+
+ @Override
public void computeDiff(Feature previous, Feature current, Feature target) {
computeDiff(previous.getBundles(), current.getBundles(), target);
}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/ConfigurationsComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/ConfigurationsComparator.java
index 718e5d4..6f3e529 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/ConfigurationsComparator.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/ConfigurationsComparator.java
@@ -25,6 +25,11 @@ import org.apache.sling.feature.diff.spi.FeatureElementComparator;
final class ConfigurationsComparator implements FeatureElementComparator {
@Override
+ public String getId() {
+ return "configurations";
+ }
+
+ @Override
public void computeDiff(Feature previous, Feature current, Feature target) {
computeDiff(previous.getConfigurations(), current.getConfigurations(), target);
}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/ExtensionsComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/ExtensionsComparator.java
index c8a0555..e64a0c9 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/ExtensionsComparator.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/ExtensionsComparator.java
@@ -35,6 +35,11 @@ final class ExtensionsComparator implements FeatureElementComparator {
private final ObjectMapper objectMapper = new ObjectMapper();
@Override
+ public String getId() {
+ return "extensions";
+ }
+
+ @Override
public void computeDiff(Feature previous, Feature current, Feature target) {
computeDiff(previous.getExtensions(), current.getExtensions(), target);
}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
index 8e982d9..19e8c00 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
@@ -26,22 +26,16 @@ import org.apache.sling.feature.diff.spi.FeatureElementComparator;
public final class FeatureDiff {
- public static Feature compareFeatures(Feature previous, Feature current, String resultId) {
- resultId = requireNonNull(resultId, "Impossible to create the Feature diff with a null id");
-
- ArtifactId id = ArtifactId.parse(resultId);
- return compareFeatures(previous, current, id);
- }
-
- public static Feature compareFeatures(Feature previous, Feature current, ArtifactId resultId) {
- previous = requireNonNull(previous, "Impossible to compare null previous feature.");
- current = requireNonNull(current, "Impossible to compare null current feature.");
+ public static Feature compareFeatures(DiffRequest diffRequest) {
+ requireNonNull(diffRequest, "");
+ Feature previous = requireNonNull(diffRequest.getPrevious(), "Impossible to compare null previous feature.");
+ Feature current = requireNonNull(diffRequest.getCurrent(), "Impossible to compare null current feature.");
if (previous.getId().equals(current.getId())) {
throw new IllegalArgumentException("Input Features refer to the the same Feature version.");
}
- resultId = requireNonNull(resultId, "Impossible to create the Feature diff with a null id");
+ ArtifactId resultId = requireNonNull(diffRequest.getResultId(), "Impossible to create the Feature diff with a null id");
Feature target = new Feature(resultId);
target.setTitle(previous.getId() + " to " + current.getId());
@@ -51,7 +45,12 @@ public final class FeatureDiff {
target.setPrototype(prototype);
for (FeatureElementComparator comparator : load(FeatureElementComparator.class)) {
- comparator.computeDiff(previous, current, target);
+ boolean included = !diffRequest.getIncludeComparators().isEmpty() ? diffRequest.getIncludeComparators().contains(comparator.getId()) : true;
+ boolean excluded = diffRequest.getExcludeComparators().contains(comparator.getId());
+
+ if (included && !excluded) {
+ comparator.computeDiff(previous, current, target);
+ }
}
return target;
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/FrameworkPropertiesComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/FrameworkPropertiesComparator.java
index 1d4ce1a..7308805 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/FrameworkPropertiesComparator.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/FrameworkPropertiesComparator.java
@@ -27,6 +27,11 @@ import org.apache.sling.feature.diff.spi.FeatureElementComparator;
final class FrameworkPropertiesComparator implements FeatureElementComparator {
@Override
+ public String getId() {
+ return "framework-properties";
+ }
+
+ @Override
public void computeDiff(Feature previous, Feature current, Feature target) {
computeDiff(previous.getFrameworkProperties(), current.getFrameworkProperties(), target);
}