yang-data-api: use yang.common.Decimal64 for decimal64 leaves

Description

Using BigDecimal does not really work for handling of decimal64 type semantics. It does not enforce the set of allowed ranges, nor values.

Create a dedicated subclass of java.lang.Number, which will implement exact http://tools.ietf.org/html/rfc6020#section-9.3 decimal64 as a long field to hold the value and the scaling value (1-18). Comparable<Decimal64> needs to be implemented (using adjusting scales as needed). The toString() should emit the canonical representation. valueOf(String) should accept any legal representation.

A migration strategy for NormalizedNode users needs to be devised, as a straight switchover would break current users, who assume BigDecimal. This should probably involve a 'TypeValueSupport' interface, which would be used to access the value inside the leaf. Implementations would perform dynamic translation as needed.

Evaluate the resulting interface for use in the solution for YANGTOOLS-418.

Activity

Show:

Robert Varga March 1, 2016 at 3:26 PM

Preliminary patch https://git.opendaylight.org/gerrit/#/c/31897/, needs to be finished.

Former user March 1, 2016 at 12:57 PM

Consider putting Decimal64 to yang-common or util, so it is available also to Java Binding, without direct need of dependening on yang-data-api

Done

Details

Assignee

Reporter

Fix versions

Priority

Created November 23, 2015 at 10:29 PM
Updated February 6, 2025 at 2:17 PM
Resolved March 13, 2022 at 3:27 PM