[YANGTOOLS-918] Reconsider design of yang.common.Revision Created: 15/Nov/18  Updated: 05/Jan/24  Resolved: 05/Jan/24

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: 12.0.0

Type: Improvement Priority: Medium
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.


Generated at Wed Feb 07 20:54:40 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.