<!-- 
RSS generated by JIRA (8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d) at Wed Feb 07 20:09:06 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>OpenDaylight JIRA</title>
    <link>https://jira.opendaylight.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.20.10</version>
        <build-number>820010</build-number>
        <build-date>22-06-2022</build-date>
    </build-info>


<item>
            <title>[MDSAL-218] *Builder classes for &quot;type union&quot; YANG gen. code should have private constructor</title>
                <link>https://jira.opendaylight.org/browse/MDSAL-218</link>
                <project id="10137" key="MDSAL">mdsal</project>
                    <description>&lt;p&gt;Background: I&apos;m currently working on a number of fixes for &lt;a href=&quot;https://github.com/vorburger/xtendbeans&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/vorburger/xtendbeans&lt;/a&gt; (AKA AssertBeans), as Genius &amp;amp; netvirt developers are starting to pick up using this utility, respectively its adaptation to ODL known as AssertDataObjects from org.opendaylight.mdsal.binding.testutils org.opendaylight.mdsal:mdsal-binding-test-utils, because that utility does not yet work with &quot;type union&quot; YANG gen. code, such as e.g. the IpAddress type.  (FYI the &lt;a href=&quot;https://git.opendaylight.org/gerrit/#/c/50137/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/#/c/50137/&lt;/a&gt; has a non-regression type for the upcoming fixes in org.opendaylight.mdsal.binding.testutils / ch.vorburger.xtendbeans.)&lt;/p&gt;

&lt;p&gt;While doing this work, I noticed that YANG gen. (stub) code for union type *Builder classes does not have a private constructor, as I would argue they all should have - even if users manually extend those *Builder classes - because users would be adding constructors with additional arguments, never implement the default constructor.&lt;/p&gt;

&lt;p&gt;For example, the org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.union.rev150121.UnionTestTypeBuilder found in org.opendaylight.mdsal:mdsal-binding-test-model:0.10.0-SNAPSHOT looks like this:&lt;/p&gt;

&lt;p&gt;    public class UnionTestTypeBuilder {&lt;br/&gt;
        public static UnionTestType getDefaultInstance(java.lang.String defaultValue) {&lt;/p&gt;

&lt;p&gt;but, IMHO, is missing this:&lt;/p&gt;

&lt;p&gt;        private UnionTestTypeBuilder() { }&lt;/p&gt;

&lt;p&gt;I can see that e.g. IpAddressBuilder (from mdsal/model/ietf/ietf-inet-types) has such a private constructor, but that seems to have been manually added after that *Builder was originally generated.  A number of other code. gen. and not manually edited union type *Builder classes do not have this private constructor - this bug suggests to extend the code generator templates to add this.&lt;/p&gt;

&lt;p&gt;This would help make it clear to any developers that these kind of *Builder classes are never meant to be instantiated with their no-args default constructor.&lt;/p&gt;

&lt;p&gt;BTW: Personally I find the naming of these *Builder classes a little unfortunate, because they look more like *Factory than *Builder - like they don&apos;t have any setter methods, don&apos;t implement org.opendaylight.yangtools.concepts.Builder and thus no build() - these really are a different concept, and having named them *Builder is more confusing than if they were simply named *Factory, or anything else other than *Builder - but it&apos;s probably way too late to change this - or is it?&lt;/p&gt;</description>
                <environment>&lt;p&gt;Operating System: All&lt;br/&gt;
Platform: All&lt;/p&gt;</environment>
        <key id="27040">MDSAL-218</key>
            <summary>*Builder classes for &quot;type union&quot; YANG gen. code should have private constructor</summary>
                <type id="10104" iconUrl="https://jira.opendaylight.org/secure/viewavatar?size=xsmall&amp;avatarId=10303&amp;avatarType=issuetype">Bug</type>
                                                <status id="5" iconUrl="https://jira.opendaylight.org/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="JieHan2017">Jie Han</assignee>
                                    <reporter username="vorburger">Michael Vorburger</reporter>
                        <labels>
                    </labels>
                <created>Mon, 9 Jan 2017 16:24:16 +0000</created>
                <updated>Fri, 9 Mar 2018 18:00:18 +0000</updated>
                            <resolved>Tue, 13 Feb 2018 11:54:29 +0000</resolved>
                                                    <fixVersion>Oxygen</fixVersion>
                                    <component>Binding codegen</component>
                    <component>Binding V2 codegen</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="54550" author="vrpolak" created="Mon, 9 Jan 2017 18:01:29 +0000"  >&lt;p&gt;If I understand it correctly, &quot;typedef&quot; may contain both &quot;default&quot; and &quot;type&quot; based on &quot;union&quot;, so zero argument constructor could make sense for constructing the default value.&lt;br/&gt;
But there may be better mechanisms for creating the default instance than argument-less constructor.&lt;/p&gt;

&lt;p&gt;Fix of &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-49&quot; title=&quot;Do not generate Builders for Union types&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-49&quot;&gt;&lt;del&gt;MDSAL-49&lt;/del&gt;&lt;/a&gt; would probably also fix this, but it may be easier to fix this without fixing &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-49&quot; title=&quot;Do not generate Builders for Union types&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-49&quot;&gt;&lt;del&gt;MDSAL-49&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As for *Builder vs *Factory, there already are multiple &quot;manual&quot; union &quot;builders&quot;, so it is too late to change API or naming.&lt;br/&gt;
But future auto-generated classes are free to implement Builder interface.&lt;/p&gt;</comment>
                            <comment id="54551" author="pkajsa" created="Tue, 10 Jan 2017 08:06:03 +0000"  >&lt;p&gt;binding generator issue, hence moved to md-sal&lt;/p&gt;</comment>
                            <comment id="60963" author="jiehan2017" created="Wed, 7 Feb 2018 08:50:51 +0000"  >&lt;p&gt;&lt;a href=&quot;https://git.opendaylight.org/gerrit/68004&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/68004&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;https://git.opendaylight.org/gerrit/68005&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/68005&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                            <customfield id="customfield_11400" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10208" key="com.atlassian.jira.plugin.system.customfieldtypes:textfield">
                        <customfieldname>External issue ID</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7498</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10201" key="com.atlassian.jira.plugin.system.customfieldtypes:url">
                        <customfieldname>External issue URL</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[https://bugs.opendaylight.org/show_bug.cgi?id=7498]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10206" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Issue Type</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10305"><![CDATA[Improvement]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10000" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|i02x1j:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>