Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use boolean or Boolean in a Spring Boot RestController?

Tags:

spring-boot

Make it any difference to use in the following snippet boolean filterMode or Boolean filterMode? Are they any best practice ? Or its completley irrelevant?

@GetMapping
public NOTMATTER getResultByBoolean(
 @RequestParam(value = "filterMode", required = false) boolean filterMode) {

  //.....

}
like image 885
Tristate Avatar asked Jul 07 '26 19:07

Tristate


1 Answers

Yes it will matter. As you have specified the parameter to be optional, if it is not supplied then default values will be different

// Boolean - default value is null
// boolean - default value is false
like image 59
Briggo Avatar answered Jul 14 '26 15:07

Briggo