79456987

Date: 2025-02-21 10:09:56
Score: 2.5
Natty:
Report link

I am facing the same problem, and unfortunately there isn't a direct way to solve this.

But you can create some sort of enum that contains three values: TRUE, FALSE and NULL, and then assign to the Boolean one of the three values with a switch-case. Like so:

public enum BooleanValue {
    
    TRUE, FALSE, NULL;

}


@POST
public String setMethod(
    @QueryParam("value1") @DefaultValue(BooleanValue.NULL) BooleanValue value1)


Boolean boolValue1;    
switch(value1) {

    case BooleanValue.TRUE:
        boolValue1 = Boolean.TRUE;
        break;

    case BooleanValue.FALSE:
        boolValue1 = Boolean.FALSE;
        break;

    default:
        break;
}

Since there isn't a case for BooleanValue.NULL, it should remain null.

Reasons:
  • Blacklisted phrase (1): m facing the same problem
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I am facing the same problem
Posted by: Marco Frag Delle Monache