{"id":8719,"date":"2012-09-25T23:21:30","date_gmt":"2012-09-25T17:51:30","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=8719"},"modified":"2012-09-25T23:23:54","modified_gmt":"2012-09-25T17:53:54","slug":"tupleconstructor-annotation-in-groovy","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/tupleconstructor-annotation-in-groovy\/","title":{"rendered":"TupleConstructor annotation in Groovy"},"content":{"rendered":"<p>@TupleConstructor annotation provides the classical constructor with default properties. It will create the constructor with first parameter as <strong>address<\/strong>, second parameter <strong>as name<\/strong> etc. Constructor implementation depends upon the order of the variable declaration. One thing you need to ensure that you need to pass the value in same order as used in variable declaration.<\/p>\n<p style=\"padding-bottom: 10px\">\n<p>Here is the example:<\/p>\n<p>[groovy]<br \/>\nimport groovy.transform.TupleConstructor<br \/>\n@TupleConstructor<br \/>\nclass Person {<br \/>\n    String address<br \/>\n    String name<br \/>\n    String city<br \/>\n    int age<br \/>\n}<\/p>\n<p>Person person1 = new Person(&#8216;ADDD&#8217;,&#8217;MOHIT&#8217;,&#8217;CITY&#8217;,1)<\/p>\n<p>println(&quot;name:::&quot;+person1.name)<br \/>\nprintln(&quot;adreess:::&quot;+person1.address)<br \/>\nprintln(&quot;city:::&quot;+person1.city)<br \/>\nprintln(&quot;age:::&quot;+person1.age)<br \/>\n[\/groovy]<\/p>\n<p style=\"padding-bottom: 10px\">\n<p>Hope this code will help you \ud83d\ude42<\/p>\n<p style=\"padding-bottom: 10px\">\n","protected":false},"excerpt":{"rendered":"<p>@TupleConstructor annotation provides the classical constructor with default properties. It will create the constructor with first parameter as address, second parameter as name etc. Constructor implementation depends upon the order of the variable declaration. One thing you need to ensure that you need to pass the value in same order as used in variable declaration. [&hellip;]<\/p>\n","protected":false},"author":47,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[1],"tags":[9],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8719"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=8719"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8719\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=8719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=8719"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=8719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}