Skip to content

Commit

Permalink
Simply mapping code
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Steinbeck committed Dec 16, 2023
1 parent b913145 commit 9c75ffe
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -152,12 +151,11 @@ public Optional<Mappable<T>> getSuccessor(
*/
public Optional<Mappable<T>> getPredecessor(
final Mappable<T> mappable) {
return mapping.entrySet()
return mapping.keySet()
.stream()
.filter(entry -> getSuccessor(entry.getKey())
.filter(predecessor -> getSuccessor(predecessor)
.orElseThrow(IllegalStateException::new)
== mappable)
.map(Map.Entry::getKey)
.findFirst();
}

Expand All @@ -183,7 +181,7 @@ public List<Mappable<T>> getWithSuccessor() {
*/
public List<Mappable<T>> getWithoutSuccessor() {
return getFrom().stream()
.filter(m -> !getSuccessor(m).isPresent())
.filter(m -> getSuccessor(m).isEmpty())
.collect(Collectors.toList());
}

Expand All @@ -209,7 +207,7 @@ public List<Mappable<T>> getWithPredecessor() {
*/
public List<Mappable<T>> getWithoutPredecessor() {
return getTo().stream()
.filter(m -> !getPredecessor(m).isPresent())
.filter(m -> getPredecessor(m).isEmpty())
.collect(Collectors.toList());
}
}
Expand Down Expand Up @@ -499,7 +497,7 @@ private static <T> Optional<Mappable<T>> applyChanges(
}

// The file was not changed.
if (!fileChange.isPresent()) {
if (fileChange.isEmpty()) {
// File of range in current revision.
final VCSFile file = findRelevantFile(range, revision)
.orElseThrow(() -> new IllegalArgumentException(
Expand Down

0 comments on commit 9c75ffe

Please sign in to comment.