title: Make Spring java object request parameter required
body: <p>I have the following controller code</p>
  
  <pre><code>@GetMapping("/users")
  public ResponseEntity&lt;UserDto&gt; getUsers(Filter filter) {
      return ResponseEntity.ok(userService.findUsers(filter));
  }
  </code></pre>
  
  <p>Filter.java:</p>
  
  <pre><code>public class Filter {
      private Integer page;
  
      private Integer size;
  
      private String sort;
  
      ... lots of other parameters
  }
  </code></pre>
  
  <p>The request parameters are written as a Java object to avoid adding lots of parameters to controller. However, all of the parameters are made optional by Spring. What I want is to have some parameters like <code>page</code> and <code>size</code> required, but others like <code>sort</code> optional. If I had them as controller parameters, I could use <code>@RequestParam(required = true/false)</code>. Is it possible to do something similar in Java class?</p>