title: Cannot set readonly property: class for class in groovy when initializing with map
body: <p>I am trying to create a class and initialize all the values with a default value. So i have this pojo in groovy, and i have created initializeWithDefaults method to initialize all the values. I am trying to pass map in the constructor</p>
  
  <pre><code>class MDS {
      String id
      String mdsName
      String name
      String mdsType
      String mdsContext
      String mdsDateTime
      String mdsDomain
  
      public static void initializeWithDefaults() {
          MDS dataSegmentIdDef = new MDS()
          Map&lt;String, Object&gt; prop = dataSegmentIdDef.properties
          prop.each { Map.Entry entry-&gt;
              entry.value = "default-${entry.key}"
          }
  
          MDS dataSegmentId = new MDS(prop)
  
      }
  }
  </code></pre>
  
  <p>but i keep getting the error </p>
  
  <pre><code>in thread "main" groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: class for class: com.ambuj.domain.MDS 
  </code></pre>