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.