title: adding a custom constructor without losing the default map constructor
body: <p>By default every Groovy class has a Map constructor, e.g.</p>
  
  <pre><code>class Foo {
    def a
    def b
  }
  
  // this works
  new Foo(a: '1', b: '2')
  </code></pre>
  
  <p>However, it seems that as soon as you add a constructor of your own, this default constructor is not available</p>
  
  <pre><code>class Foo {
  
    Foo(Integer x) {
      println 'my constructor was called'  
    }
  
    def a
    def b
  }
  
  // this works
  new Foo(1)
  
  // now this doesn't work, I get the error: groovy.lang.GroovyRuntimeException: 
  // failed to invoke constructor
  new Foo(a: '1', b: '2')
  </code></pre>
  
  <p><strong>Is it possible to add your own constructor without losing the default map constructor?</strong> I tried annotating the class with <code>@TupleConstructor</code> but it made no difference. I realise I could add the map constructor myself, e.g.</p>
  
  <pre><code>public Foo(Map map) {    
    map?.each { k, v -&gt; this[k] = v }  
  }
  </code></pre>
  
  <p>Though the constructor above is not identical to the default map constructor because a key in the map that does not have a corresponding property in the class will cause an exception.</p>