[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 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. |