Skip to content

Commit

Permalink
fix: CreateXml generate with content
Browse files Browse the repository at this point in the history
  • Loading branch information
pstreef committed Jul 26, 2024
1 parent 84f5858 commit 2fbadad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public TreeVisitor<?, ExecutionContext> getScanner(AtomicBoolean shouldCreate) {
@Override
public Collection<SourceFile> generate(AtomicBoolean shouldCreate, ExecutionContext ctx) {
if (shouldCreate.get()) {
return PropertiesParser.builder().build().parse(!StringUtils.isBlank(fileContents) ? fileContents : "")
return PropertiesParser.builder().build().parse(fileContents == null ? "" : fileContents)
.map(brandNewFile -> (SourceFile) brandNewFile.withSourcePath(Paths.get(relativeFileName)))
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public TreeVisitor<?, ExecutionContext> getScanner(AtomicBoolean shouldCreate) {
@Override
public Collection<SourceFile> generate(AtomicBoolean shouldCreate, ExecutionContext ctx) {
if (shouldCreate.get()) {
return XmlParser.builder().build().parse("")
return XmlParser.builder().build().parse(fileContents == null ? "" : fileContents)
.map(brandNewFile -> (SourceFile) brandNewFile.withSourcePath(Paths.get(relativeFileName)))
.collect(Collectors.toList());
}
Expand All @@ -94,7 +94,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor(AtomicBoolean created) {
return new XmlVisitor<ExecutionContext>() {
@Override
public Xml visitDocument(Xml.Document document, ExecutionContext ctx) {
if ((created.get() || Boolean.TRUE.equals(overwriteExisting)) && path.equals(document.getSourcePath())) {
if (Boolean.TRUE.equals(overwriteExisting) && path.equals(document.getSourcePath())) {
if (StringUtils.isBlank(fileContents)) {
return document.withProlog(null).withRoot(null);
}
Expand Down

0 comments on commit 2fbadad

Please sign in to comment.