title: How to add conditional based @NotNull constraint in spring boot?
body: <p>We are using <code>spring-boot</code>.
  I want to add conditional based constraint in java class.
  For e.g.</p>
  
  <pre><code>@Entity
  public class User {
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      @Column(name = "user_id")
      private Integer userId;
      @Column(name = "firstName")
      private String firstName;
      @Column(name = "lastName")
      private String lastName;
  }
  </code></pre>
  
  <p>Now in above code I want to put <code>@NotNull</code> constraint on <code>lastName</code> property if and only if the <code>firstName</code> property is not empty.</p>