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

Reconsider design of yang.common.Revision

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Medium Medium
    • 12.0.0
    • None
    • None

      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.

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

              Created:
              Updated:
              Resolved: