title: Kotlin generate constructor that sets default values to nulled arguments
body: <p>Let's take the class of a data class:</p>
  
  <pre><code>data class User(
      val userNumber: Int = -1,
      val name: String,
      val userGroups; List&lt;String&gt; = emptyList(),
      val screenName: String = "new-user"
  )
  </code></pre>
  
  <p>When calling this function from Kotlin, it is pretty straightforward. I can simply use the named-argument syntax to do so. Calling from Java, I have to specify all values, or use the <code>@JvmOverloads</code> annotation, which generates the following constructors (in addition to the constructor that kotlin generates with the bit-mask for default values):</p>
  
  <pre><code>User(int userNumber, @NotNull String name, @NotNull List userGroups,
       @NotNull String screenName)
  User(int userNumber, @NotNull String name, @NotNull List userGroups)
  User(int userNumber, @NotNull String name)
  User(@NotNull String name)
  </code></pre>
  
  <p>Now, if I want to create a <code>User</code> object in Java equivalent to <code>User(name="John Doe", userGroups=listOf("admin", "super")</code> I can't do it with the above constructors. I CAN however do it if I put <code>val userNumber: Int = -1</code> at the end in the <code>data class</code> declaration (the generation of constructors seems to depend on the order the optional arguments are defined in). Which is fine, because expecting kotlin to generate all permutations is going to heavily bloat some classes.</p>
  
  <p>The biggest problem that tools like <code>Jackson</code> simply don't work as they have no idea which constructor to use (and not like I can annotate one of the generated ones specially).</p>
  
  <p>So, is there a way to generate a (single) constructor like:</p>
  
  <pre><code>User(Integer userNumber, String name, List&lt;String&gt; userGroups, String screenName) {
      this.userNumber = (userNumber == null) ? -1 : userNumber;
      this.userGroups = (userGroups == null) ? Collections.emptyList() : userGroups;
      //...
  }
  </code></pre>
  
  <p>Currently I am using the above approach, but manually defining the constructors where I need them.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I should clarify, creating a similar constructor doesn't work, obviously because both the signatures would clash on the JVM. This is what it would like in my case:</p>
  
  <pre><code>data class User(
      val userNumber: Int = -1,
      val name: String,
      val userGroups; List&lt;String&gt; = emptyList(),
      val screenName: String = "new-user"
  ) {
      companion object {
          @JvmStatic
          @JsonCreator
          fun constructionSupport(
              @JsonProperty("userNumber") userNumber : Int?,
              @JsonProperty("name") name : String,
              @JsonProperty("userGroups") userGroups : List&lt;String&gt;?,
              @JsonProperty("screenName") screenName : String?
          ) = User(
              userNumber = userNumber ?: -1,
              name = name,
              userGroups = userGroups ?: emptyList(),
              screenName = screenName ?: "new-user"
          )
      }
  }
  </code></pre>
  
  <p>Also note the redundancy where I have to write the default values for the properties twice. I Now that I look at it, I doubt there exists a solution for this. Maybe this is a good use-case for a <code>kapt</code> based side-project of mine :)</p>