79094604

Date: 2024-10-16 14:52:39
Score: 1
Natty:
Report link

I found the best way for me. How to hide rows where values are null, 0. Guava doesn't help me , because guava does int as string , but "0" value, it isn't null value ,so i coudn't hide rows if row is int

My way:

public static void appendIfStringNotNull(StringBuilder stringBuilder, String msgForAppend ,String field) {

if (field != null && !field.isEmpty()) {

    stringBuilder.append(msgForAppend).append(field).append(", ");

}

}

public static void appendIfIntegerNotNull(StringBuilder stringBuilder, String msgForAppend ,Integer field) {

if (field != null && field != 0) {

    stringBuilder.append(msgForAppend).append(field).append(", ");

}

}

public String toString() {

StringBuilder sb = new StringBuilder();

Building.appendIfStringNotNull(sb, "Place: ", place);

Building.appendIfIntegerNotNull(sb, "Height: ", height);

Building.appendIfIntegerNotNull(sb, "Width: ", width);

return sb.length() > 0 ? sb.substring(0, sb.length() - 2) : "";

}

Reasons:
  • Blacklisted phrase (1): help me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Zhenia Ho