Skip to content

Commit

Permalink
Declare AlreadyReplaced#find as @Nullable
Browse files Browse the repository at this point in the history
It was already used in this way by some recipes.
  • Loading branch information
knutwannheden committed Feb 20, 2025
1 parent 927957d commit 69dd3c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
@With
public class AlreadyReplaced implements Marker {
UUID id;

@Nullable
String find;

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private Xml.Tag updateUsingRegex(Xml.Tag t, Xml.CharData content) {
if (oldMarkers
.findAll(AlreadyReplaced.class)
.stream()
.noneMatch(m -> m.getFind().equals(oldValue) && newValue.equals(m.getReplace()))) {
.noneMatch(m -> oldValue.equals(m.getFind()) && newValue.equals(m.getReplace()))) {
return t.withContent(singletonList(content
.withText(text.replaceAll(oldValue, newValue))
.withMarkers(oldMarkers.add(new AlreadyReplaced(randomId(), oldValue, newValue)))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public AppendToSequenceVisitor(JsonPathMatcher matcher, String value, @Nullable
public Yaml.Sequence visitSequence(Yaml.Sequence existingSeq, ExecutionContext ctx) {
Cursor parent = getCursor().getParent();
if (matcher.matches(parent) &&
!existingSeq.getMarkers().findFirst(AlreadyReplaced.class).filter(m -> m.getFind().equals(value)).isPresent() &&
!existingSeq.getMarkers().findFirst(AlreadyReplaced.class).filter(m -> value.equals(m.getFind())).isPresent() &&
checkExistingSequenceValues(existingSeq, parent)) {
return appendToSequence(existingSeq, this.value, ctx);
}
Expand Down

0 comments on commit 69dd3c7

Please sign in to comment.