Skip to content

Commit

Permalink
change Nan value to No value into logs (#261)
Browse files Browse the repository at this point in the history
Signed-off-by: Maissa SOUISSI <[email protected]>
  • Loading branch information
souissimai authored Jun 7, 2023
1 parent 0038a34 commit fb236d4
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class ModificationUtils {

public static final String DISCONNECTOR = "disconnector_";
public static final String BREAKER = "breaker_";
public static final String NO_VALUE = "No value";

private ModificationUtils() {
}
Expand Down Expand Up @@ -418,8 +419,10 @@ public <T> Report buildModificationReport(T oldValue, T newValue, String fieldNa
}

public <T> Report buildModificationReportWithIndentation(T oldValue, T newValue, String fieldName, int indentationLevel) {
String oldValueString = oldValue == null ? "NaN" : oldValue.toString();
String newValueString = newValue == null ? "NaN" : newValue.toString();
boolean isOldValueDoubleNaN = (oldValue instanceof Double) && Double.isNaN((Double) oldValue);
String oldValueString = (oldValue == null || isOldValueDoubleNaN) ? NO_VALUE : oldValue.toString();
boolean isNewValueDoubleNaN = (newValue instanceof Double) && Double.isNaN((Double) newValue);
String newValueString = (newValue == null || isNewValueDoubleNaN) ? NO_VALUE : newValue.toString();
StringBuilder indentation = new StringBuilder();
for (int i = 0; i < indentationLevel; i++) {
indentation.append(" ");
Expand Down Expand Up @@ -518,7 +521,7 @@ public void setCurrentLimits(CurrentLimitsInfos currentLimitsInfos, CurrentLimit
}

public <T> Report buildCreationReport(T value, String fieldName) {
String newValueString = value == null ? "NaN" : value.toString();
String newValueString = value == null ? NO_VALUE : value.toString();
return Report.builder()
.withKey("Creation" + fieldName)
.withDefaultMessage(" ${fieldName} : ${value}")
Expand Down

0 comments on commit fb236d4

Please sign in to comment.