Skip to content

Commit

Permalink
Insert "-" for empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOellerer committed Jan 16, 2025
1 parent 9cfbdf4 commit 8b4a470
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group 'com.docutools'
version = '8.2.0'
version = '9.0.0-alpha.1'

java {
toolchain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private Optional<PlaceholderData> doReflectiveResolve(String placeholderName, Lo
}
var wrappedProperty = getBeanProperty(placeholderName);
if (wrappedProperty.isEmpty()) {
return Optional.of(new ScalarPlaceholderData<>("-"));
return Optional.of(new ScalarPlaceholderData<>(""));
}
return toPlaceholderData(placeholderName, locale, wrappedProperty.get());
} catch (NoSuchMethodException | IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public PlaceholderType getType() {

@Override
public String toString() {
return stringifier.apply(value);
String string = stringifier.apply(value);
if (string == null || string.isEmpty()) {
return "-";
}
return string;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private ModificationInformation replacePlaceholder(Cell cell, int offset) {
// to resolve cell content such as "{{name}} {{crew}}", we match against the full string and resolve per match
var matcher = ParsingUtils.matchPlaceholders(cellValue);
excelWriter.addCell(cell, matcher.replaceAll(matchResult -> resolver.resolve(matchResult.group(1))
.orElse(new ScalarPlaceholderData<>("-"))
.orElse(new ScalarPlaceholderData<>(""))
.toString()));
return ModificationInformation.empty();
}
Expand Down

0 comments on commit 8b4a470

Please sign in to comment.