Remove part of guava uses
Change-Id: Ifb6e5b5bf391d540b3738b501c68221065a21a1b
diff --git a/plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF
index b0bf519..2f63722 100644
--- a/plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.compare/META-INF/MANIFEST.MF
@@ -44,5 +44,4 @@
com.google.common.cache;version="[15.0.0,22.0.0)",
com.google.common.collect;version="[15.0.0,22.0.0)",
com.google.common.eventbus;version="[15.0.0,22.0.0)",
- com.google.common.util.concurrent;version="[15.0.0,22.0.0)",
org.apache.log4j;version="[1.2.15,2.0.0)"
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/EMFCompare.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/EMFCompare.java
index 82f3009..d75ffc9 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/EMFCompare.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/EMFCompare.java
@@ -13,8 +13,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.collect.Iterators;
-
import java.util.Iterator;
import java.util.List;
@@ -370,7 +368,11 @@
EList<Match> matches = comparison.getMatches();
for (Match match : matches) {
matchQuantity++;
- matchQuantity += Iterators.size(match.getAllSubmatches().iterator());
+ Iterator<Match> subMatchIterator = match.getAllSubmatches().iterator();
+ while (subMatchIterator.hasNext()) {
+ matchQuantity++;
+ subMatchIterator.next();
+ }
}
LOGGER.info("compare() - FINISH - " + matchQuantity + " matches, " + diffQuantity + " diffs and " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ conflictQuantity + " conflicts found in " + duration + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
index 27b721c..300b684 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
@@ -19,10 +19,11 @@
import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices;
import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.Monitor;
@@ -96,7 +97,8 @@
}
final Diff diff = differences.get(i);
- checkConflict(comparison, diff, Iterables.filter(differences, possiblyConflictingWith(diff)));
+ Stream<Diff> conflictCandidates = differences.stream().filter(possiblyConflictingWith(diff));
+ checkConflict(comparison, diff, conflictCandidates::iterator);
}
if (LOGGER.isInfoEnabled()) {
@@ -124,15 +126,19 @@
// CHANGE diffs can only conflict with other CHANGE or DELETE ... here again detected on the DELETE
// MOVE diffs can conflict with DELETE ones, detected on the delete, or with other MOVE diffs.
if (diff instanceof ReferenceChange && ((ReferenceChange)diff).getReference().isContainment()) {
- checkContainmentConflict(comparison, (ReferenceChange)diff,
- Iterables.filter(candidates, ReferenceChange.class));
+ Stream<ReferenceChange> conflictCandidates = StreamSupport.stream(candidates.spliterator(), false)
+ .filter(ReferenceChange.class::isInstance).map(ReferenceChange.class::cast);
+ checkContainmentConflict(comparison, (ReferenceChange)diff, conflictCandidates::iterator);
} else if (diff instanceof ResourceAttachmentChange) {
// These will be handled about the same way as containment deletions,
// Though they can also conflict with themselves
checkResourceAttachmentConflict(comparison, (ResourceAttachmentChange)diff, candidates);
} else if (isFeatureMapContainment(diff)) {
+ Stream<FeatureMapChange> conflictCandidates = StreamSupport
+ .stream(candidates.spliterator(), false).filter(FeatureMapChange.class::isInstance)
+ .map(FeatureMapChange.class::cast);
checkContainmentFeatureMapConflict(comparison, (FeatureMapChange)diff,
- Iterables.filter(candidates, FeatureMapChange.class));
+ conflictCandidates::iterator);
} else {
switch (diff.getKind()) {
case DELETE:
@@ -473,21 +479,22 @@
return;
}
- final Iterable<Diff> refinedCandidates = Iterables.filter(candidates, new Predicate<Diff>() {
- public boolean apply(Diff input) {
- boolean apply = false;
- if (input != null && input.getKind() == DifferenceKind.CHANGE) {
- if (input instanceof ReferenceChange) {
- apply = ((ReferenceChange)input).getReference() == feature;
- } else if (input instanceof AttributeChange) {
- apply = ((AttributeChange)input).getAttribute() == feature;
- } else if (input instanceof FeatureMapChange) {
- apply = ((FeatureMapChange)input).getAttribute() == feature;
+ final Iterable<Diff> refinedCandidates = StreamSupport.stream(candidates.spliterator(), false)
+ .filter(new Predicate<Diff>() {
+ public boolean apply(Diff input) {
+ boolean apply = false;
+ if (input != null && input.getKind() == DifferenceKind.CHANGE) {
+ if (input instanceof ReferenceChange) {
+ apply = ((ReferenceChange)input).getReference() == feature;
+ } else if (input instanceof AttributeChange) {
+ apply = ((AttributeChange)input).getAttribute() == feature;
+ } else if (input instanceof FeatureMapChange) {
+ apply = ((FeatureMapChange)input).getAttribute() == feature;
+ }
+ }
+ return apply;
}
- }
- return apply;
- }
- });
+ })::iterator;
final IEqualityHelper equalityHelper = comparison.getEqualityHelper();
@@ -657,21 +664,22 @@
return;
}
- final Iterable<Diff> refinedCandidates = Iterables.filter(candidates, new Predicate<Diff>() {
- public boolean apply(Diff input) {
- boolean apply = false;
- if (input != null && input.getKind() == DifferenceKind.MOVE) {
- if (input instanceof ReferenceChange) {
- apply = ((ReferenceChange)input).getReference() == feature;
- } else if (input instanceof AttributeChange) {
- apply = ((AttributeChange)input).getAttribute() == feature;
- } else if (input instanceof FeatureMapChange) {
- apply = ((FeatureMapChange)input).getAttribute() == feature;
+ final Iterable<Diff> refinedCandidates = StreamSupport.stream(candidates.spliterator(), false)
+ .filter(new Predicate<Diff>() {
+ public boolean apply(Diff input) {
+ boolean apply = false;
+ if (input != null && input.getKind() == DifferenceKind.MOVE) {
+ if (input instanceof ReferenceChange) {
+ apply = ((ReferenceChange)input).getReference() == feature;
+ } else if (input instanceof AttributeChange) {
+ apply = ((AttributeChange)input).getAttribute() == feature;
+ } else if (input instanceof FeatureMapChange) {
+ apply = ((FeatureMapChange)input).getAttribute() == feature;
+ }
+ }
+ return apply;
}
- }
- return apply;
- }
- });
+ })::iterator;
for (Diff candidate : refinedCandidates) {
final Object candidateValue = getDiffValue(candidate);
@@ -724,22 +732,23 @@
* that value on the opposite side (the "feature" cannot be a containment reference, those are handled
* through #checkContainmentDeleteConflict).
*/
- final Iterable<Diff> refinedCandidates = Iterables.filter(candidates, new Predicate<Diff>() {
- public boolean apply(Diff input) {
- boolean apply = false;
- if (input != null && (input.getKind() == DifferenceKind.MOVE
- || input.getKind() == DifferenceKind.DELETE)) {
- if (input instanceof ReferenceChange) {
- apply = ((ReferenceChange)input).getReference() == feature;
- } else if (input instanceof AttributeChange) {
- apply = ((AttributeChange)input).getAttribute() == feature;
- } else if (input instanceof FeatureMapChange) {
- apply = ((FeatureMapChange)input).getAttribute() == feature;
+ final Iterable<Diff> refinedCandidates = StreamSupport.stream(candidates.spliterator(), false)
+ .filter(new Predicate<Diff>() {
+ public boolean apply(Diff input) {
+ boolean apply = false;
+ if (input != null && (input.getKind() == DifferenceKind.MOVE
+ || input.getKind() == DifferenceKind.DELETE)) {
+ if (input instanceof ReferenceChange) {
+ apply = ((ReferenceChange)input).getReference() == feature;
+ } else if (input instanceof AttributeChange) {
+ apply = ((AttributeChange)input).getAttribute() == feature;
+ } else if (input instanceof FeatureMapChange) {
+ apply = ((FeatureMapChange)input).getAttribute() == feature;
+ }
+ }
+ return apply;
}
- }
- return apply;
- }
- });
+ })::iterator;
for (Diff candidate : refinedCandidates) {
final Object movedValue = getDiffValue(candidate);
@@ -791,22 +800,23 @@
* Can only conflict on Diffs : of type ADD, on the opposite side, in the same container and the same
* reference, with the same added value.
*/
- final Iterable<Diff> refinedCandidates = Iterables.filter(candidates, new Predicate<Diff>() {
- public boolean apply(Diff input) {
- boolean apply = false;
- if (input != null
- && (input.getKind() == DifferenceKind.ADD && diff.getMatch() == input.getMatch())) {
- if (input instanceof ReferenceChange) {
- apply = ((ReferenceChange)input).getReference() == feature;
- } else if (input instanceof AttributeChange) {
- apply = ((AttributeChange)input).getAttribute() == feature;
- } else if (input instanceof FeatureMapChange) {
- apply = ((FeatureMapChange)input).getAttribute() == feature;
+ final Iterable<Diff> refinedCandidates = StreamSupport.stream(candidates.spliterator(), false)
+ .filter(new Predicate<Diff>() {
+ public boolean apply(Diff input) {
+ boolean apply = false;
+ if (input != null && (input.getKind() == DifferenceKind.ADD
+ && diff.getMatch() == input.getMatch())) {
+ if (input instanceof ReferenceChange) {
+ apply = ((ReferenceChange)input).getReference() == feature;
+ } else if (input instanceof AttributeChange) {
+ apply = ((AttributeChange)input).getAttribute() == feature;
+ } else if (input instanceof FeatureMapChange) {
+ apply = ((FeatureMapChange)input).getAttribute() == feature;
+ }
+ }
+ return apply;
}
- }
- return apply;
- }
- });
+ })::iterator;
for (Diff candidate : refinedCandidates) {
final Object candidateValue = getDiffValue(candidate);
@@ -1008,8 +1018,10 @@
// [477607] DELETE does not necessarily mean that the element is removed from the model
EObject o = getRelatedModelElement(diff);
if (o != null && o.eContainer() == null) {
- for (Diff extendedCandidate : Iterables.filter(match.getAllDifferences(),
- possiblyConflictingWith(diff))) {
+ Iterable<Diff> extendedCandidates = StreamSupport
+ .stream(match.getAllDifferences().spliterator(), false)
+ .filter(possiblyConflictingWith(diff))::iterator;
+ for (Diff extendedCandidate : extendedCandidates) {
if (isDeleteOrUnsetDiff(extendedCandidate)) {
// We do not want to create a pseudo conflict between a deleted container and its
// deleted content, since that would prevent us from merging the container deletion
@@ -1176,7 +1188,7 @@
final List<Diff> conflictDiffs = conflict.getDifferences();
if (toBeMerged != null) {
// These references are opposite. We can't simply iterate
- for (Diff aDiff : Lists.newArrayList(toBeMerged.getDifferences())) {
+ for (Diff aDiff : new ArrayList<>(toBeMerged.getDifferences())) {
if (!conflictDiffs.contains(aDiff)) {
conflictDiffs.add(aDiff);
}
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/FeatureFilter.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/FeatureFilter.java
index be3f3c6..e1830ae 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/FeatureFilter.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/FeatureFilter.java
@@ -12,9 +12,6 @@
import static org.eclipse.emf.compare.utils.EMFComparePredicates.IS_EGENERIC_TYPE_WITHOUT_PARAMETERS;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterators;
-
import java.util.Iterator;
import org.eclipse.emf.compare.Match;
@@ -65,11 +62,7 @@
} else {
clazz = match.getOrigin().eClass();
}
- return Iterators.filter(clazz.getEAllReferences().iterator(), new Predicate<EReference>() {
- public boolean apply(EReference input) {
- return !isIgnoredReference(match, input);
- }
- });
+ return clazz.getEAllReferences().stream().filter(ref -> !isIgnoredReference(match, ref)).iterator();
}
/**
@@ -95,11 +88,7 @@
} else {
clazz = match.getOrigin().eClass();
}
- return Iterators.filter(clazz.getEAllAttributes().iterator(), new Predicate<EAttribute>() {
- public boolean apply(EAttribute input) {
- return !isIgnoredAttribute(input);
- }
- });
+ return clazz.getEAllAttributes().stream().filter(att -> !isIgnoredAttribute(att)).iterator();
}
/**
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/equi/DefaultEquiEngine.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/equi/DefaultEquiEngine.java
index 478f4c3..bfef8fa 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/equi/DefaultEquiEngine.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/equi/DefaultEquiEngine.java
@@ -11,10 +11,7 @@
*******************************************************************************/
package org.eclipse.emf.compare.equi;
-import static com.google.common.collect.Iterables.filter;
-
import com.google.common.base.Predicate;
-import com.google.common.collect.Sets;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -151,7 +148,8 @@
return false;
}
};
- final Iterable<Diff> candidates = filter(valueMatch.getDifferences(), candidateFilter);
+ final Iterable<Diff> candidates = valueMatch.getDifferences().stream()
+ .filter(candidateFilter)::iterator;
for (Diff candidate : candidates) {
equivalence.getDifferences().add(candidate);
@@ -230,9 +228,11 @@
}
final EStructuralFeature entryKey = ((FeatureMap.Entry)featureMapEntry).getEStructuralFeature();
- final Set<ReferenceChange> equivalentDiffs = Sets.newLinkedHashSet();
+ final Set<ReferenceChange> equivalentDiffs = new LinkedHashSet<>();
final IEqualityHelper equalityHelper = comparison.getEqualityHelper();
- for (ReferenceChange refChange : filter(differences, ReferenceChange.class)) {
+ Iterable<ReferenceChange> refChanges = differences.stream()
+ .filter(ReferenceChange.class::isInstance).map(ReferenceChange.class::cast)::iterator;
+ for (ReferenceChange refChange : refChanges) {
// The current diff has the same ref & value than the Map Entry of the FeatureMapChange.
boolean sameValue = equalityHelper.matchingValues(refChange.getValue(), entryValue);
boolean sameSource = featureMapChange.getSource() == refChange.getSource();
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AbstractConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AbstractConflictSearch.java
index 87c86ae..c462108 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AbstractConflictSearch.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AbstractConflictSearch.java
@@ -14,14 +14,14 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Sets.newLinkedHashSet;
import static org.eclipse.emf.compare.ConflictKind.PSEUDO;
import static org.eclipse.emf.compare.ConflictKind.REAL;
import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -311,7 +311,7 @@
final EList<Diff> conflictDiffs = conflict.getDifferences();
if (toBeMerged != null) {
// These references are opposite. We can't simply iterate
- for (Diff aDiff : Lists.newArrayList(toBeMerged.getDifferences())) {
+ for (Diff aDiff : new ArrayList<>(toBeMerged.getDifferences())) {
conflictDiffs.add(aDiff);
}
if (toBeMerged.getKind() == REAL && conflict.getKind() != REAL) {
@@ -321,8 +321,8 @@
toBeMerged.getDifferences().clear();
}
- Set<Diff> toAdd = newLinkedHashSet();
- for (Diff conflicting : ImmutableSet.of(diff, other)) {
+ Set<Diff> toAdd = new LinkedHashSet<>();
+ for (Diff conflicting : Arrays.asList(diff, other)) {
if (conflicting.getEquivalence() == null) {
toAdd.add(conflicting);
} else {
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AttributeChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AttributeChangeConflictSearch.java
index 1a0b03b..1bda5f3 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AttributeChangeConflictSearch.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AttributeChangeConflictSearch.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.emf.compare.internal.conflict;
-import static com.google.common.base.Predicates.and;
-import static com.google.common.base.Predicates.instanceOf;
import static org.eclipse.emf.compare.ConflictKind.PSEUDO;
import static org.eclipse.emf.compare.ConflictKind.REAL;
import static org.eclipse.emf.compare.DifferenceKind.ADD;
@@ -23,8 +21,6 @@
import static org.eclipse.emf.compare.utils.EMFComparePredicates.possiblyConflictingWith;
import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices;
-import com.google.common.collect.Iterables;
-
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.compare.AttributeChange;
@@ -62,16 +58,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
EAttribute feature = diff.getAttribute();
// Only unique features can have real conflicts
Object value = diff.getValue();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- Iterable<Diff> conflictCandidates = Iterables.filter(diffsInSameMatch,
- and(possiblyConflictingWith(diff), instanceOf(AttributeChange.class), onFeature(feature),
- ofKind(ADD)));
+ Iterable<Diff> conflictCandidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(AttributeChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(ADD)))::iterator;
if (feature.isUnique()) {
for (Diff candidate : conflictCandidates) {
Object candidateValue = ((AttributeChange)candidate).getValue();
@@ -167,14 +162,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Object value = diff.getValue();
EAttribute feature = diff.getAttribute();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(AttributeChange.class), onFeature(feature), ofKind(CHANGE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(AttributeChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(CHANGE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((AttributeChange)candidate).getValue();
if (comparison.getEqualityHelper().matchingValues(value, candidateValue)) {
// Same value added on both side in the same container
@@ -207,14 +203,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Object value = diff.getValue();
EAttribute feature = diff.getAttribute();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(AttributeChange.class), onFeature(feature), ofKind(MOVE, DELETE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(AttributeChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(MOVE, DELETE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((AttributeChange)candidate).getValue();
if (comparison.getEqualityHelper().matchingValues(value, candidateValue)) {
if (candidate.getKind() == MOVE) {
@@ -248,14 +245,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Object value = diff.getValue();
EAttribute feature = diff.getAttribute();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(AttributeChange.class), onFeature(feature), ofKind(MOVE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(AttributeChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(MOVE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((AttributeChange)candidate).getValue();
// This can only be a conflict if the value moved is the same
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ContainmentRefChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ContainmentRefChangeConflictSearch.java
index 15eb58e..b912ab7 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ContainmentRefChangeConflictSearch.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ContainmentRefChangeConflictSearch.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.emf.compare.internal.conflict;
-import static com.google.common.base.Predicates.and;
-import static com.google.common.base.Predicates.instanceOf;
import static org.eclipse.emf.compare.ConflictKind.PSEUDO;
import static org.eclipse.emf.compare.ConflictKind.REAL;
import static org.eclipse.emf.compare.DifferenceKind.ADD;
@@ -25,8 +23,6 @@
import static org.eclipse.emf.compare.utils.EMFComparePredicates.valueMatches;
import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices;
-import com.google.common.collect.Iterables;
-
import java.util.Collection;
import org.eclipse.emf.common.util.EList;
@@ -66,7 +62,6 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
EObject value = diff.getValue();
@@ -74,8 +69,9 @@
// First let's see if non-containment diffs point to the EObject added
Collection<ReferenceChange> refChanges = index.getReferenceChangesByValue(value);
- for (ReferenceChange candidate : Iterables.filter(refChanges,
- and(possiblyConflictingWith(diff), ofKind(ADD, CHANGE)))) {
+ Iterable<ReferenceChange> candidates = refChanges.stream()
+ .filter(possiblyConflictingWith(diff).and(ofKind(ADD, CHANGE)))::iterator;
+ for (ReferenceChange candidate : candidates) {
if (candidate.getReference().isContainment()) {
if (candidate.getReference() == feature && candidate.getMatch() == diff.getMatch()) {
// added in the same feature in the same match.
@@ -101,8 +97,10 @@
// Can conflict with other ADD or SET if isMany() == false
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
if (!feature.isMany()) {
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(ReferenceChange.class), onFeature(feature), ofKind(ADD, CHANGE)))) {
+ Iterable<Diff> additionalCandidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(ReferenceChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(ADD, CHANGE)))::iterator;
+ for (Diff candidate : additionalCandidates) {
if (comparison.getEqualityHelper().matchingValues(((ReferenceChange)candidate).getValue(),
diff.getValue())) {
conflict(candidate, PSEUDO);
@@ -135,7 +133,6 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
EObject value = diff.getValue();
@@ -143,8 +140,9 @@
// First let's see if non-containment diffs point to the EObject added
Collection<ReferenceChange> refChanges = index.getReferenceChangesByValue(value);
- for (ReferenceChange candidate : Iterables.filter(refChanges,
- and(possiblyConflictingWith(diff), ofKind(ADD, CHANGE)))) {
+ Iterable<ReferenceChange> candidates = refChanges.stream()
+ .filter(possiblyConflictingWith(diff).and(ofKind(ADD, CHANGE)))::iterator;
+ for (ReferenceChange candidate : candidates) {
if (candidate.getReference().isContainment()) {
if (candidate.getReference() == feature && candidate.getMatch() == diff.getMatch()) {
conflict(candidate, PSEUDO);
@@ -157,8 +155,10 @@
// Can conflict with other ADD or SET if isMany() == false
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
if (!feature.isMany() && isAddOrSetDiff(diff)) {
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(ReferenceChange.class), onFeature(feature)))) {
+ Iterable<Diff> additionalCandidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(ReferenceChange.class::isInstance)
+ .and(onFeature(feature)))::iterator;
+ for (Diff candidate : additionalCandidates) {
if (comparison.getEqualityHelper().matchingValues(((ReferenceChange)candidate).getValue(),
diff.getValue())) {
conflict(candidate, PSEUDO);
@@ -167,8 +167,10 @@
}
}
} else if (!isDeleteOrUnsetDiff(diff)) {
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(ReferenceChange.class), onFeature(feature)))) {
+ Iterable<Diff> additionalCandidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(ReferenceChange.class::isInstance)
+ .and(onFeature(feature)))::iterator;
+ for (Diff candidate : additionalCandidates) {
if (!isDeleteOrUnsetDiff(candidate)
&& diff.getReference() == ((ReferenceChange)candidate).getReference()) {
// Same value added in the same container/reference couple
@@ -203,33 +205,27 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
EObject value = diff.getValue();
// First let's see if non-containment diffs point to the EObject deleted from its parent
Collection<ReferenceChange> refChanges = index.getReferenceChangesByValue(value);
- for (ReferenceChange candidate : Iterables.filter(refChanges, possiblyConflictingWith(diff))) {
- if (isDeleteOrUnsetDiff(candidate)) {
- // No conflict here
- } else {
- conflict(candidate, REAL);
- }
- }
+ refChanges.stream().filter(possiblyConflictingWith(diff)).filter(d -> !isDeleteOrUnsetDiff(d))
+ .forEach(d -> conflict(d, REAL));
// Now let's look for conflits with containment ReferenceChanges
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch,
- and(possiblyConflictingWith(diff), instanceOf(ReferenceChange.class),
- valueMatches(comparison.getEqualityHelper(), value)))) {
-
- if (isDeleteOrUnsetDiff(candidate)) {
- conflict(candidate, PSEUDO);
- } else {
- conflict(candidate, REAL);
- }
- }
+ diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(ReferenceChange.class::isInstance)
+ .and(valueMatches(comparison.getEqualityHelper(), value)))
+ .forEach(candidate -> {
+ if (isDeleteOrUnsetDiff(candidate)) {
+ conflict(candidate, PSEUDO);
+ } else {
+ conflict(candidate, REAL);
+ }
+ });
// [381143] Every Diff "under" a containment deletion conflicts with it.
final DiffTreeIterator diffIterator = new DiffTreeIterator(comparison.getMatch(value));
@@ -272,7 +268,6 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
EObject value = diff.getValue();
@@ -280,42 +275,44 @@
// First let's see if non-containment diffs point to the EObject added
Collection<ReferenceChange> refChanges = index.getReferenceChangesByValue(value);
- for (ReferenceChange candidate : Iterables.filter(refChanges,
- and(possiblyConflictingWith(diff), ofKind(MOVE)))) {
- if (candidate.getReference().isContainment()) {
- // This is a containment move. It is the only case in which we could have a "move"
- // difference in a reference where order is not significant
- if (candidate.getReference() == feature && candidate.getMatch() == diff.getMatch()) {
- // Same element has been moved into the same container on both sides. If we care about
- // ordering in this new containment reference, check the indices to detect potential
- // real conflicts.
- FeatureFilter featureFilter = getFeatureFilter(comparison);
- if (featureFilter == null || featureFilter.checkForOrderingChanges(feature)) {
- if (matchingIndices(diff.getMatch(), feature, value, candidate.getValue())) {
- conflict(candidate, PSEUDO);
- } else {
- conflict(candidate, REAL);
- }
- } else {
+ Iterable<ReferenceChange> candidates = refChanges.stream()
+ .filter(possiblyConflictingWith(diff).and(ofKind(MOVE)))
+ .filter(d -> d.getReference().isContainment())::iterator;
+ for (ReferenceChange candidate : candidates) {
+ // This is a containment move. It is the only case in which we could have a "move"
+ // difference in a reference where order is not significant
+ if (candidate.getReference() == feature && candidate.getMatch() == diff.getMatch()) {
+ // Same element has been moved into the same container on both sides. If we care about
+ // ordering in this new containment reference, check the indices to detect potential
+ // real conflicts.
+ FeatureFilter featureFilter = getFeatureFilter(comparison);
+ if (featureFilter == null || featureFilter.checkForOrderingChanges(feature)) {
+ if (matchingIndices(diff.getMatch(), feature, value, candidate.getValue())) {
conflict(candidate, PSEUDO);
+ } else {
+ conflict(candidate, REAL);
}
} else {
- conflict(candidate, REAL);
+ conflict(candidate, PSEUDO);
}
- }
- }
-
- EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch,
- and(possiblyConflictingWith(diff), valueMatches(comparison.getEqualityHelper(), value),
- instanceOf(ReferenceChange.class), onFeature(feature)))) {
- if (matchingIndices(diff.getMatch(), diff.getReference(), value,
- ((ReferenceChange)candidate).getValue())) {
- conflict(candidate, PSEUDO);
} else {
conflict(candidate, REAL);
}
}
+
+ EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
+ diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff)
+ .and(valueMatches(comparison.getEqualityHelper(), value))
+ .and(ReferenceChange.class::isInstance).and(onFeature(feature)))
+ .forEach(candidate -> {
+ if (matchingIndices(diff.getMatch(), diff.getReference(), value,
+ ((ReferenceChange)candidate).getValue())) {
+ conflict(candidate, PSEUDO);
+ } else {
+ conflict(candidate, REAL);
+ }
+ });
}
}
}
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/FeatureMapChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/FeatureMapChangeConflictSearch.java
index b42c2e5..8cf4568 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/FeatureMapChangeConflictSearch.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/FeatureMapChangeConflictSearch.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.emf.compare.internal.conflict;
-import static com.google.common.base.Predicates.and;
-import static com.google.common.base.Predicates.instanceOf;
import static org.eclipse.emf.compare.ConflictKind.PSEUDO;
import static org.eclipse.emf.compare.ConflictKind.REAL;
import static org.eclipse.emf.compare.DifferenceKind.ADD;
@@ -24,8 +22,6 @@
import static org.eclipse.emf.compare.utils.EMFComparePredicates.valueMatches;
import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices;
-import com.google.common.collect.Iterables;
-
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.compare.Diff;
@@ -64,7 +60,6 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
EAttribute feature = diff.getAttribute();
@@ -73,8 +68,10 @@
if (feature.isUnique()) {
Object value = diff.getValue();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(FeatureMapChange.class), onFeature(feature), ofKind(ADD)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(FeatureMapChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(ADD)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((FeatureMapChange)candidate).getValue();
if (comparison.getEqualityHelper().matchingValues(value, candidateValue)) {
// This is a conflict. Is it real?
@@ -110,14 +107,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Object value = diff.getValue();
EAttribute feature = diff.getAttribute();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(FeatureMapChange.class), onFeature(feature), ofKind(CHANGE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(FeatureMapChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(CHANGE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((FeatureMapChange)candidate).getValue();
if (comparison.getEqualityHelper().matchingValues(value, candidateValue)) {
// Same value added on both side in the same container
@@ -150,14 +148,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Object value = diff.getValue();
EAttribute feature = diff.getAttribute();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(FeatureMapChange.class), onFeature(feature), ofKind(MOVE, DELETE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(FeatureMapChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(MOVE, DELETE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((FeatureMapChange)candidate).getValue();
if (comparison.getEqualityHelper().matchingValues(value, candidateValue)) {
if (candidate.getKind() == MOVE) {
@@ -191,7 +190,6 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Match diffMatch = diff.getMatch();
@@ -199,10 +197,11 @@
Object value = entry.getValue();
EAttribute feature = diff.getAttribute();
EList<Diff> diffsInSameMatch = diffMatch.getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch,
- and(possiblyConflictingWith(diff), instanceOf(FeatureMapChange.class),
- valueMatches(comparison.getEqualityHelper(), value), onFeature(feature),
- ofKind(MOVE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(FeatureMapChange.class::isInstance)
+ .and(valueMatches(comparison.getEqualityHelper(), value)).and(onFeature(feature))
+ .and(ofKind(MOVE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((FeatureMapChange)candidate).getValue();
if (matchingIndices(diff.getMatch(), feature, value, candidateValue)) {
conflict(candidate, PSEUDO);
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/NonContainmentRefChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/NonContainmentRefChangeConflictSearch.java
index 46a035c..f179fd2 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/NonContainmentRefChangeConflictSearch.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/NonContainmentRefChangeConflictSearch.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.emf.compare.internal.conflict;
-import static com.google.common.base.Predicates.and;
-import static com.google.common.base.Predicates.instanceOf;
import static org.eclipse.emf.compare.ConflictKind.PSEUDO;
import static org.eclipse.emf.compare.ConflictKind.REAL;
import static org.eclipse.emf.compare.DifferenceKind.ADD;
@@ -23,8 +21,6 @@
import static org.eclipse.emf.compare.utils.EMFComparePredicates.possiblyConflictingWith;
import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices;
-import com.google.common.collect.Iterables;
-
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.compare.Diff;
@@ -61,7 +57,6 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
EReference feature = diff.getReference();
@@ -69,8 +64,10 @@
if (feature.isUnique()) {
Object value = diff.getValue();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(ReferenceChange.class), onFeature(feature), ofKind(ADD)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(ReferenceChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(ADD)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((ReferenceChange)candidate).getValue();
if (comparison.getEqualityHelper().matchingValues(value, candidateValue)) {
// This is a conflict. Is it real?
@@ -111,14 +108,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Object value = diff.getValue();
EReference feature = diff.getReference();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(ReferenceChange.class), onFeature(feature), ofKind(CHANGE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(ReferenceChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(CHANGE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((ReferenceChange)candidate).getValue();
if (comparison.getEqualityHelper().matchingValues(value, candidateValue)) {
// Same value added on both side in the same container
@@ -151,14 +149,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Object value = diff.getValue();
EReference feature = diff.getReference();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(ReferenceChange.class), onFeature(feature), ofKind(MOVE, DELETE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(ReferenceChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(MOVE, DELETE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((ReferenceChange)candidate).getValue();
if (comparison.getEqualityHelper().matchingValues(value, candidateValue)) {
if (candidate.getKind() == MOVE) {
@@ -192,14 +191,15 @@
super(diff, index, monitor);
}
- @SuppressWarnings("unchecked")
@Override
public void detectConflicts() {
Object value = diff.getValue();
EReference feature = diff.getReference();
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch, and(possiblyConflictingWith(diff),
- instanceOf(ReferenceChange.class), onFeature(feature), ofKind(MOVE)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream()
+ .filter(possiblyConflictingWith(diff).and(ReferenceChange.class::isInstance)
+ .and(onFeature(feature)).and(ofKind(MOVE)))::iterator;
+ for (Diff candidate : candidates) {
Object candidateValue = ((ReferenceChange)candidate).getValue();
// This can only be a conflict if the value moved is the same
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ResourceAttachmentChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ResourceAttachmentChangeConflictSearch.java
index 13eca9c..290b4fc 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ResourceAttachmentChangeConflictSearch.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ResourceAttachmentChangeConflictSearch.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.emf.compare.internal.conflict;
-import static com.google.common.base.Predicates.and;
import static com.google.common.base.Predicates.instanceOf;
import static org.eclipse.emf.compare.ConflictKind.PSEUDO;
import static org.eclipse.emf.compare.ConflictKind.REAL;
@@ -20,8 +19,6 @@
import static org.eclipse.emf.compare.internal.utils.ComparisonUtil.isDeleteOrUnsetDiff;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.possiblyConflictingWith;
-import com.google.common.collect.Iterables;
-
import java.util.Collection;
import org.eclipse.emf.common.util.EList;
@@ -72,7 +69,9 @@
// First let's see if ReferenceChanges point to the EObject moved
Collection<ReferenceChange> refChanges = index.getReferenceChangesByValue(value);
- for (ReferenceChange candidate : Iterables.filter(refChanges, possiblyConflictingWith(diff))) {
+ Iterable<ReferenceChange> candidates = refChanges.stream()
+ .filter(possiblyConflictingWith(diff))::iterator;
+ for (ReferenceChange candidate : candidates) {
if (candidate.getReference().isContainment()) {
if (candidate.getValue().eContainer() == null) {
// The element is a new root on one side, but it has been moved to an EObject
@@ -96,8 +95,9 @@
// Then let's see if there's a conflict with another ResourceAttachmentChange
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch,
- and(possiblyConflictingWith(diff), instanceOf(ResourceAttachmentChange.class)))) {
+ Iterable<Diff> racCandidates = diffsInSameMatch.stream().filter(
+ possiblyConflictingWith(diff).and(instanceOf(ResourceAttachmentChange.class)))::iterator;
+ for (Diff candidate : racCandidates) {
ConflictKind kind = REAL;
if (candidate.getKind() == ADD) {
final Resource diffRes;
@@ -174,8 +174,9 @@
// First let's see if ReferenceChanges point to the EObject moved
if (value != null) {
Collection<ReferenceChange> refChanges = index.getReferenceChangesByValue(value);
- for (ReferenceChange candidate : Iterables.filter(refChanges,
- possiblyConflictingWith(diff))) {
+ Iterable<ReferenceChange> candidates = refChanges.stream()
+ .filter(possiblyConflictingWith(diff))::iterator;
+ for (ReferenceChange candidate : candidates) {
if (candidate.getReference().isContainment()) {
// The element is a new root on one side, but it has been moved to an EObject
// container on the other
@@ -196,8 +197,9 @@
// Then let's see if there's a conflict with another ResourceAttachmentChange
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch,
- and(possiblyConflictingWith(diff), instanceOf(ResourceAttachmentChange.class)))) {
+ Iterable<Diff> racCandidates = diffsInSameMatch.stream().filter(
+ possiblyConflictingWith(diff).and(instanceOf(ResourceAttachmentChange.class)))::iterator;
+ for (Diff candidate : racCandidates) {
ConflictKind kind = REAL;
if (candidate.getKind() == DELETE) {
final Resource diffRes;
@@ -217,17 +219,12 @@
// dependence of the existing conflict
if (isDanglingRootDeletion()
&& (diff.getConflict() == null || diff.getConflict().getKind() != PSEUDO)) {
- for (Diff extendedCandidate : Iterables.filter(match.getDifferences(),
- possiblyConflictingWith(diff))) {
- if (isDeleteOrUnsetDiff(extendedCandidate)) {
- // We do not want to create a pseudo conflict between a deleted container and its
- // deleted content, since that would prevent us from merging the container deletion
- // altogether (since pseudo conflicts usually mean that no action is needed).
- // conflict(extendedCandidate, PSEUDO);
- } else {
- conflict(extendedCandidate, REAL);
- }
- }
+ // We do not want to create a pseudo conflict between a deleted container and its
+ // deleted content, since that would prevent us from merging the container deletion
+ // altogether (since pseudo conflicts usually mean that no action is needed).
+ // conflict(extendedCandidate, PSEUDO);
+ match.getDifferences().stream().filter(possiblyConflictingWith(diff))
+ .filter(d -> !isDeleteOrUnsetDiff(d)).forEach(candidate -> conflict(candidate, REAL));
}
}
@@ -277,17 +274,17 @@
// First let's see if ReferenceChanges point to the EObject moved
Collection<ReferenceChange> refChanges = index.getReferenceChangesByValue(value);
- for (ReferenceChange candidate : Iterables.filter(refChanges, possiblyConflictingWith(diff))) {
- if (candidate.getReference().isContainment()) {
- // The element is a new root on one side, but it has been moved to an EObject container on
- // the other
- conflict(candidate, REAL);
- }
- }
+
+ // The element is a new root on one side, but it has been moved to an EObject container on
+ // the other
+ refChanges.stream().filter(possiblyConflictingWith(diff))
+ .filter(candidate -> candidate.getReference().isContainment())
+ .forEach(candidate -> conflict(candidate, REAL));
EList<Diff> diffsInSameMatch = diff.getMatch().getDifferences();
- for (Diff candidate : Iterables.filter(diffsInSameMatch,
- and(possiblyConflictingWith(diff), instanceOf(ResourceAttachmentChange.class)))) {
+ Iterable<Diff> candidates = diffsInSameMatch.stream().filter(
+ possiblyConflictingWith(diff).and(instanceOf(ResourceAttachmentChange.class)))::iterator;
+ for (Diff candidate : candidates) {
ConflictKind kind = REAL;
if (candidate.getKind() == MOVE) {
String lhsURI = diff.getResourceURI();