<!-- 
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-238] YANG gen. binding classes should offer a matches(CharSequence input) [or expose Pattern[] patterns public instead private]</title>
                <link>https://jira.opendaylight.org/browse/MDSAL-238</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 wanting to access the java.util.regex.Pattern in a YANG gen. binding class, but could not because it is private.&lt;/p&gt;

&lt;p&gt;It&apos;s easy enough to recreate it from the public List&amp;lt;String&amp;gt; PATTERN_CONSTANTS, but perhaps you would consider exposing it as a public static final Pattern[] PATTERNS; as well?&lt;/p&gt;

&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;

&lt;p&gt;I&apos;ll also file a separate bug proposing to offer an additional utility method, this issue is to focus particularly just on exposing the Pattern publicly.&lt;/p&gt;</description>
                <environment>&lt;p&gt;Operating System: All&lt;br/&gt;
Platform: All&lt;/p&gt;</environment>
        <key id="27060">MDSAL-238</key>
            <summary>YANG gen. binding classes should offer a matches(CharSequence input) [or expose Pattern[] patterns public instead private]</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="10003">Cannot Reproduce</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="vorburger">Michael Vorburger</reporter>
                        <labels>
                    </labels>
                <created>Wed, 15 Mar 2017 16:35:28 +0000</created>
                <updated>Fri, 9 Mar 2018 18:00:19 +0000</updated>
                            <resolved>Wed, 29 Mar 2017 17:22:45 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="54610" author="vorburger" created="Wed, 15 Mar 2017 16:47:30 +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); if this was available, that code would have to make a little bit less of a hand-stand to recreate Pattern from String.&lt;/p&gt;</comment>
                            <comment id="54611" author="vrpolak" created="Wed, 15 Mar 2017 17:49:28 +0000"  >&lt;p&gt;&amp;gt; public static final Pattern[] PATTERNS;&lt;/p&gt;

&lt;p&gt;Do you mean this?&lt;/p&gt;

&lt;p&gt;    public Pattern[] getPatterns() &lt;/p&gt;
{
        return Arrays.copyOf(patterns, patterns.length);
    }</comment>
                            <comment id="54612" author="vorburger" created="Wed, 15 Mar 2017 18:01:15 +0000"  >&lt;p&gt;&amp;gt; Do you mean this?&lt;/p&gt;

&lt;p&gt;yes, otherwise it&apos;s mutable (even if final, the array elements could be changed, which we certainly wouldn&apos;t want...) so yeah that is what actually I meant... thanks! &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;&lt;/p&gt;</comment>
                            <comment id="54613" author="vorburger" created="Thu, 16 Mar 2017 07:49:06 +0000"  >&lt;p&gt;actually on further thought, having to Arrays.copyOf() for every time you getPatterns() isn&apos;t ideal, if it can be avoided, so it would be better to just offer something like:&lt;/p&gt;

&lt;p&gt;public static final List&amp;lt;Pattern&amp;gt; PATTERNS = ImmutableList.of(PATTERN_CONSTANTS.transform(...));&lt;/p&gt;

&lt;p&gt;This is more consistent with the existing PATTERN_CONSTANTS.  Or, if a method like getPatterns(), then it should be &quot;static&quot; (above it is not).  But having a public field for the String pattern but a static getter for the regexp Pattern object isn&apos;t consistent.&lt;/p&gt;</comment>
                            <comment id="54614" author="rovarga" created="Thu, 16 Mar 2017 08:46:55 +0000"  >&lt;p&gt;I do not quite get the use case. Why do you need to programmatically access the pattern?&lt;/p&gt;</comment>
                            <comment id="54615" author="rovarga" created="Thu, 16 Mar 2017 09:06:46 +0000"  >&lt;p&gt;Also details how the value validity is enforced is an implementation-private detail, which can change at any time and we certainly do not want application code to be tied to that.&lt;/p&gt;

&lt;p&gt;More specifically, the pattern strings exposed are the strings coming from the model and are useful for reporting. They are not guaranteed to pass Pattern.compile() &amp;#8211; they just happen to do so because &lt;a href=&quot;https://jira.opendaylight.org/browse/YANGTOOLS-587&quot; title=&quot;Parser: XSD regular expressions are interpreted as Java regexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;YANGTOOLS-587&quot;&gt;&lt;del&gt;YANGTOOLS-587&lt;/del&gt;&lt;/a&gt; was left unaddressed for a long time. Now that has happened, PATTERN_CONSTANTS will actually contain raw patterns and an internal constant will carry the strings for enforcement.&lt;/p&gt;</comment>
                            <comment id="54616" author="vorburger" created="Thu, 16 Mar 2017 09:57:05 +0000"  >&lt;p&gt;&amp;gt; Why do you need to programmatically access the pattern?&lt;/p&gt;

&lt;p&gt;to be able to check whether a String matches the pattern, as in &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; (originally motivated out of code 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;).&lt;/p&gt;

&lt;p&gt;&amp;gt; details how the value validity is enforced is an implementation-private&lt;br/&gt;
&amp;gt; More specifically, the pattern strings exposed are the strings coming&lt;br/&gt;
&amp;gt; from the model and are useful for reporting. They are&lt;br/&gt;
&amp;gt; not guaranteed to pass Pattern.compile()&lt;/p&gt;

&lt;p&gt;OK, all the more reason then to offer a better API than just exposing String?&lt;/p&gt;

&lt;p&gt;What would also work here, instead of exposing a Pattern instance as originally suggested, and may be better, is to just directly offer a method with a signature like:&lt;/p&gt;

&lt;p&gt;   public static boolean matches(CharSequence input)&lt;/p&gt;

&lt;p&gt;because this is what I want to have access to the pattern for anyway - and I can&apos;t think of anything else one would want to do with a Pattern, anyway.  (PS: Going this way may also prevent stupid API users from making a concurrency mistake; Pattern is thread safe, Matcher is not - just having a matches() takes away any possible room for misuse of this.)&lt;/p&gt;

&lt;p&gt;Or just completely forget about this and only do &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;? Although I think both have potential uses (and an implementation of &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; could be built upon a matches(), as could those generated constructors which, currently, internally do pattern.matcher(_value).matches()).&lt;/p&gt;</comment>
                            <comment id="54617" author="vrpolak" created="Thu, 16 Mar 2017 15:28:32 +0000"  >&lt;p&gt;If the intent is to create a binding object when the argument matches, the only reliable solution is &lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt;. For example the string subtype can have length constraints aside of patterns.&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;2&amp;#93;&lt;/span&gt; &lt;a href=&quot;https://bugs.opendaylight.org/show_bug.cgi?id=7992#c3&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://bugs.opendaylight.org/show_bug.cgi?id=7992#c3&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="54618" author="rovarga" created="Mon, 27 Mar 2017 14:37:50 +0000"  >&lt;p&gt;Michael, I don&apos;t want to sound negative, but what kind of business logic relies on external constraints (defined by the model) to decide what class of object to instantiate?&lt;/p&gt;

&lt;p&gt;I mean this sounds like you really want to be instatianting a union of some kind, rather than having a clearly-defined model &amp;#8211; if you have a fallback type which is more general than UUID, why not use that?&lt;/p&gt;</comment>
                            <comment id="54619" author="vorburger" created="Mon, 27 Mar 2017 15:02:39 +0000"  >&lt;p&gt;&amp;gt; what kind of business logic relies on external constraints&lt;br/&gt;
&amp;gt; (defined by the model) to decide what class of object to instantiate?&lt;br/&gt;
&amp;gt; sounds like you really want to be instatianting a union of some kind,&lt;br/&gt;
&amp;gt; rather than having a clearly-defined model &amp;#8211; if you have a fallback&lt;br/&gt;
&amp;gt; type which is more general than UUID, why not use that?&lt;/p&gt;

&lt;p&gt;well in the case of how they solved &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; in c/53118, it actually does not even instantiate either this or that, it&apos;s just a dumb &quot;if it&apos;s that then do this, else do nothing&quot; check.  I&apos;m not yet familiar enough with the details of the netvirt model and that code to be able to judge if this really is more an indication of some sort of underlying design flaw which, in an ideal world, should be conceptually addressed more globally, by a new union YANG type on that model, or otherwise - you may well be perfectly right that it is!  This issue was merely created out of the realization of an existing case where it was handled by checking the constraint explicitly.&lt;/p&gt;

&lt;p&gt;As stated in &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; I won&apos;t loose sleep over if we just close this and forget about it.&lt;/p&gt;</comment>
                            <comment id="54620" author="vrpolak" created="Wed, 29 Mar 2017 17:22:45 +0000"  >&lt;p&gt;&amp;gt; you really want to be instatianting a union of some kind&lt;/p&gt;

&lt;p&gt;Exactly. I see benefits of recognizing specific types (perhaps the input is from some less strongly typed protocol), but unions (as opposed to ad-hoc Java binding enhancements) are there exactly for that kind of data.&lt;/p&gt;

&lt;p&gt;&amp;gt; in an ideal world, should be conceptually addressed more globally,&lt;br/&gt;
&amp;gt; by a new union YANG type on that model, or otherwise&lt;/p&gt;

&lt;p&gt;You can create my-internal-maybe-uuid-union.yang in your sub-project to hold the typedef for your implementation to use, without affecting anyone else (perhaps after asking upstream projects if they wish to host that first).&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>7991</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=7991]]></customfieldvalue>

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

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