Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-918

Reconsider design of yang.common.Revision

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Medium
    • Resolution: Done
    • None
    • 12.0.0
    • None

    Description

      Current design of QNameModule returning Optional<Revision> may be sub-optimal as evidenced in CONTROLLER-1871 and the fact we need Revision.compare(Optional, Optional) and its nullable counterpart.

      Reconsider the design such that there are two subclasses of Revision, present and missing, and think about how users can access the underlying string: it is very usual for users to do

      QNameModule.getRevision().map(Revision::toString).orElse(null)
      

      or

      QNameModule.getRevision().map(Revision::toString).orElse("")
      

      We could perhaps cater to these with a

      class QNameModule {
        Optional<String> getRevisionString() {
          return revision == null ? Optional.empty() : Optional.of(revision.toString());
        }
      
        @Nullable String revisionString() {
          return revision == null ? null : revision.toString();
        }
      }
      

      and then reflect these perhaps in QName as well.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            rovarga Robert Varga
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: