<!-- 
RSS generated by JIRA (8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d) at Wed Feb 07 20:09:11 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-239] YANG gen. binding classes with Optional&lt;XYZ&gt; newXYZIfValidPattern() kind of utility factory method</title>
                <link>https://jira.opendaylight.org/browse/MDSAL-239</link>
                <project id="10137" key="MDSAL">mdsal</project>
                    <description>&lt;p&gt;In &lt;a href=&quot;https://git.opendaylight.org/gerrit/#/c/53118/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/#/c/53118/&lt;/a&gt; for &lt;a href=&quot;https://jira.opendaylight.org/browse/NETVIRT-514&quot; title=&quot;QosInterfaceStateChangeListener: java.lang.IllegalArgumentException&quot; class=&quot;issue-link&quot; data-issue-key=&quot;NETVIRT-514&quot;&gt;&lt;del&gt;NETVIRT-514&lt;/del&gt;&lt;/a&gt; I found myself writing a small utility with a method like this:&lt;/p&gt;

&lt;p&gt;Optional&amp;lt;Uuid&amp;gt; newUuidIfValidPattern(String possibleUuid)&lt;/p&gt;

&lt;p&gt;in class UuidUtil; about to be proposed into org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil also.&lt;/p&gt;

&lt;p&gt;I&apos;m wondering if this is an extreme rare case, or not something one might reasonably often encounter wanting to do - perhaps you would consider generating such a utility factory method returning an Optional for all classes generated for regexp expression in YANG, so that in the case of above org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid would have this directly?&lt;/p&gt;

&lt;p&gt;Also see &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-238&quot; title=&quot;YANG gen. binding classes should offer a matches(CharSequence input) [or expose Pattern[] patterns public instead private]&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-238&quot;&gt;&lt;del&gt;MDSAL-238&lt;/del&gt;&lt;/a&gt; for a related more minor suggestion.&lt;/p&gt;</description>
                <environment>&lt;p&gt;Operating System: All&lt;br/&gt;
Platform: All&lt;/p&gt;</environment>
        <key id="27061">MDSAL-239</key>
            <summary>YANG gen. binding classes with Optional&lt;XYZ&gt; newXYZIfValidPattern() kind of utility factory method</summary>
                <type id="10100" iconUrl="https://jira.opendaylight.org/secure/viewavatar?size=xsmall&amp;avatarId=10310&amp;avatarType=issuetype">Improvement</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="10001">Won&apos;t Do</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="vorburger">Michael Vorburger</reporter>
                        <labels>
                    </labels>
                <created>Wed, 15 Mar 2017 16:40:01 +0000</created>
                <updated>Fri, 9 Mar 2018 18:00:19 +0000</updated>
                            <resolved>Tue, 18 Apr 2017 11:02:25 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="54621" author="vorburger" created="Wed, 15 Mar 2017 16:47:29 +0000"  >&lt;p&gt;&lt;a href=&quot;https://git.opendaylight.org/gerrit/#/c/53363/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/#/c/53363/&lt;/a&gt; has a one of manual related thing (for Uuid); this issue basically proposes to generalize and auto-generate that kind of helper.&lt;/p&gt;</comment>
                            <comment id="54622" author="vorburger" created="Wed, 15 Mar 2017 16:47:51 +0000"  >&lt;p&gt;Not sure if this has to be depending on &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-237&quot; title=&quot;Milestone: Implement Binding Specification - Java v2&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-237&quot;&gt;&lt;del&gt;MDSAL-237&lt;/del&gt;&lt;/a&gt; Binding Specification Java v2, or could already be done in v1 - what&apos;s the risk, after all?&lt;/p&gt;</comment>
                            <comment id="54623" author="vrpolak" created="Wed, 15 Mar 2017 18:06:25 +0000"  >&lt;p&gt;I guess this code is too long or slow for you?&lt;/p&gt;

&lt;p&gt;    try &lt;/p&gt;
{
        maybeUuid = Optional&amp;lt;Uuid&amp;gt;.of(new Uuid(myString));
    }
&lt;p&gt; catch (IllegalArgumentException exception) &lt;/p&gt;
{
        maybeUuid = Optional&amp;lt;Uuid&amp;gt;.empty();
    }

&lt;p&gt;Binding Specification Java v2 currently does not plan to offer any &quot;createIfValidElseEmpty&quot; methods.&lt;/p&gt;</comment>
                            <comment id="54624" author="vorburger" created="Thu, 16 Mar 2017 07:45:32 +0000"  >&lt;p&gt;&amp;gt;  } catch (IllegalArgumentException exception) {&lt;/p&gt;

&lt;p&gt;This isn&apos;t great, if for any reason code expects this path to be often travelled, then AFAIK catching an exception in a &quot;normal&quot; code path (not an &quot;exceptional&quot; one, which is supposed to happen rarely) is a bad anti-pattern with known performance issues on the JVM?  I&apos;m aware that there are some optimizations re. this deep in the JVM (e.g. if you throw/catch the same Exception a lot, then its skips creating a stack trace and you get weird exceptions which have no stack trace, apparently), but... this is a hack.  IMHO you should check for something which you know may throw an exception by another mean, if you can.&lt;/p&gt;

&lt;p&gt;This is why I believe it could be valuable for gen. code to offer a util for this use case.&lt;/p&gt;</comment>
                            <comment id="54625" author="rovarga" created="Thu, 16 Mar 2017 09:00:04 +0000"  >&lt;p&gt;Well, the question is, how do you expect to recover from having an illegal argument. To me it feels like the model and application are not aligned at all.&lt;/p&gt;</comment>
                            <comment id="54626" author="vorburger" created="Thu, 16 Mar 2017 10:03:48 +0000"  >&lt;p&gt;&amp;gt; how do you expect to recover from having an illegal argument. &lt;/p&gt;

&lt;p&gt;dunno, up to the calling code, thus the Optional.  The scenario here is code &#224; la: &quot;if this String which I got from somewhere is a (some type, like Uuid) then I want to do that, otherwise I want to do this &lt;span class=&quot;error&quot;&gt;&amp;#91;which may be nothing&amp;#93;&lt;/span&gt;&quot;.&lt;/p&gt;

&lt;p&gt;&amp;gt; To me it feels like the model and application are not aligned at all.&lt;/p&gt;

&lt;p&gt;That&apos;s entirely possible, but I have run into at least one (c/53118/ for &lt;a href=&quot;https://jira.opendaylight.org/browse/NETVIRT-514&quot; title=&quot;QosInterfaceStateChangeListener: java.lang.IllegalArgumentException&quot; class=&quot;issue-link&quot; data-issue-key=&quot;NETVIRT-514&quot;&gt;&lt;del&gt;NETVIRT-514&lt;/del&gt;&lt;/a&gt;) real world need where having this would have been useful, and have thus opened this bug to suggest a general API to simplify the little handstand for a one-off solution for a particular type I&apos;m making in c/53363 for future users of YANG binding gen. code.&lt;/p&gt;</comment>
                            <comment id="54627" author="vrpolak" created="Thu, 16 Mar 2017 15:23:20 +0000"  >&lt;p&gt;I agree with this sentence from &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;:&lt;br/&gt;
  ideally, everything should be &quot;strongly typed&quot;&lt;/p&gt;

&lt;p&gt;For now, I think the performance hit is the appropriate punishment for an application &quot;guessing&quot; what the argument really is.&lt;/p&gt;

&lt;p&gt;The correct fix it to wait for &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; and then implement maybe-uuid as a union type in a utility Yang model.&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt; &lt;a href=&quot;https://bugs.opendaylight.org/show_bug.cgi?id=7913#c1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://bugs.opendaylight.org/show_bug.cgi?id=7913#c1&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="54628" author="martin.ciglan" created="Mon, 27 Mar 2017 11:50:56 +0000"  >&lt;p&gt;Hi Michael&lt;/p&gt;

&lt;p&gt;Have you got any more thoughts/conclusions about 7991 &amp;amp; 7992 so we know if to confirm these bugs or not. Many thanks.&lt;/p&gt;</comment>
                            <comment id="54629" author="vorburger" created="Mon, 27 Mar 2017 14:47:45 +0000"  >&lt;p&gt;&amp;gt; appropriate punishment&lt;/p&gt;

&lt;p&gt;I don&apos;t like punishment...&lt;/p&gt;

&lt;p&gt;&amp;gt; The correct fix it to wait for &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; and then&lt;br/&gt;
&amp;gt; implement maybe-uuid as a union type in a utility Yang model.&lt;/p&gt;

&lt;p&gt;I see the idea (I think), but that hard-codes this into the model - I&apos;m not sure you&apos;d want that.  There may truly be cases when from a model PoV something rightfully has regexp/lenght constraint, but you want to check some input against &quot;could this be a&quot; - without incurring the exception overhead? It seems, from what I understand, that &lt;a href=&quot;https://jira.opendaylight.org/browse/NETVIRT-514&quot; title=&quot;QosInterfaceStateChangeListener: java.lang.IllegalArgumentException&quot; class=&quot;issue-link&quot; data-issue-key=&quot;NETVIRT-514&quot;&gt;&lt;del&gt;NETVIRT-514&lt;/del&gt;&lt;/a&gt; was such a case - I doubt one would want to change the YANG model for Port in netvirt just because of that bug.&lt;/p&gt;

&lt;p&gt;&amp;gt; more thoughts/conclusions about &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-238&quot; title=&quot;YANG gen. binding classes should offer a matches(CharSequence input) [or expose Pattern[] patterns public instead private]&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-238&quot;&gt;&lt;del&gt;MDSAL-238&lt;/del&gt;&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-239&quot; title=&quot;YANG gen. binding classes with Optional&amp;lt;XYZ&amp;gt; newXYZIfValidPattern() kind of utility factory method&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-239&quot;&gt;&lt;del&gt;MDSAL-239&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;personally I do still think both or at least one of these can be useful.. &lt;/p&gt;

&lt;p&gt;If it makes things easier if we choose just one of the two, then I think this issues captures the essence of the intended use case better than the lower level &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-238&quot; title=&quot;YANG gen. binding classes should offer a matches(CharSequence input) [or expose Pattern[] patterns public instead private]&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-238&quot;&gt;&lt;del&gt;MDSAL-238&lt;/del&gt;&lt;/a&gt;; so if you like we can keep this and close that one?&lt;/p&gt;

&lt;p&gt;But I do sense that Robert&apos;s &amp;amp; Vratko&apos;s don&apos;t see this as something &quot;critical&quot; - and it&apos;s tree that you can work around it and achieve the same yourself in custom code; the point of this was to suggest an enhancement as a convenience short-cut when one wants to do this (which isn&apos;t every day, but the case has come up in the real world, thus I filed this).  &lt;/p&gt;

&lt;p&gt;So if there is very strong disagreement, then just do just close it - this isn&apos;t the sort of issue I&apos;d be inclined to &quot;defend&quot; or &quot;fight for&quot; &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.opendaylight.org/images/icons/emoticons/wink.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; at all - it was an idea which I thought of and basically still think has value, for some cases.&lt;/p&gt;</comment>
                            <comment id="54630" author="vrpolak" created="Thu, 30 Mar 2017 11:08:26 +0000"  >&lt;p&gt;&amp;gt; you want to check some input against &quot;could this be a&quot;&lt;/p&gt;

&lt;p&gt;Is this check any different from &quot;deserialize a union&quot;?&lt;br/&gt;
Unions should be modeled.&lt;/p&gt;

&lt;p&gt;&amp;gt; but that hard-codes this into the model&lt;/p&gt;

&lt;p&gt;The union typedef can be in any model (that includes models typedefing the constituents). Any *-impl.yang will do.&lt;/p&gt;</comment>
                            <comment id="54631" author="martin.ciglan" created="Tue, 18 Apr 2017 09:29:39 +0000"  >&lt;p&gt;Michael, have you got any objections if I close this ticket? Thanks.&lt;/p&gt;</comment>
                            <comment id="54632" author="vorburger" created="Tue, 18 Apr 2017 10:02:32 +0000"  >&lt;p&gt;&amp;gt; Michael, have you got any objections if I close this ticket? Thanks.&lt;/p&gt;

&lt;p&gt;No objection, your honour.&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>7992</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=7992]]></customfieldvalue>

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

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