yangtools.git
5 weeks agoUse JsonWriter.nullValue() 72/111172/1
Robert Varga [Tue, 2 Apr 2024 08:29:14 +0000 (10:29 +0200)]
Use JsonWriter.nullValue()

We are passing a null String, which ends up calling to nullValue().
Short-circuit this.

Change-Id: I75423bee13cb2d73ef1b817b975a9cb155721c02
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoWriteout primitive boolean 71/111171/1
Robert Varga [Tue, 2 Apr 2024 08:21:13 +0000 (10:21 +0200)]
Writeout primitive boolean

We know the value is non-null, hence we can short-circuit to
JsonWriter.value(boolean).

Change-Id: I9340c2ebd8adfe34323e13f35a74ae78d24c2ce2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoAdd JSONCodec.parseValue(String) 59/111159/1
Robert Varga [Mon, 1 Apr 2024 18:12:36 +0000 (20:12 +0200)]
Add JSONCodec.parseValue(String)

JSONCodec's parsing does not have a document context, add convenience
a convenience method.

JIRA: YANGTOOLS-1567
Change-Id: Iae1329be54bcb2f9249d0a159b4aa316be2e8d3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 weeks agoImprove Revision.toString() javadoc 85/110685/1
Robert Varga [Tue, 12 Mar 2024 21:53:21 +0000 (22:53 +0100)]
Improve Revision.toString() javadoc

Revision.toString() has a few guarantees, make sure we document them.

Change-Id: I80ba05c9ac99ab8928e48eb33ad9e9216bddf61e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 weeks agoBump versions to 13.0.3-SNAPSHOT 68/110668/1
Robert Varga [Tue, 12 Mar 2024 14:31:59 +0000 (15:31 +0100)]
Bump versions to 13.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: I41edd29c96e94e531aa973e2ebf1ff28a571aefc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 weeks agoRelease yangtools v13.0.2
jenkins-releng [Tue, 12 Mar 2024 10:39:59 +0000 (10:39 +0000)]
Release yangtools

2 months agoFix Guava javadoc reference 62/110462/1
Robert Varga [Sun, 3 Mar 2024 19:53:22 +0000 (20:53 +0100)]
Fix Guava javadoc reference

We have a down-revved reference, fix it up.

Change-Id: I88daa1d63919885e4cb1e0e4a26d6aa563e33e24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoBump odlparent to 13.0.11 31/110431/1
Robert Varga [Fri, 1 Mar 2024 21:32:28 +0000 (22:32 +0100)]
Bump odlparent to 13.0.11

Pick up latest upgrades from upstream.

Change-Id: I2b9e3d9f9e9b80d563f7004bb3558f3767817e2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 months agoImprove YangParserTestUtils 10/110310/1
Robert Varga [Fri, 23 Feb 2024 07:58:55 +0000 (08:58 +0100)]
Improve YangParserTestUtils

Annotate method returns with @NonNull and ditch the use of
checkArgument().

Change-Id: I62b0da68bffb5cd50dc6dcb3bb755454a9575b52
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake Empty hashcode deterministic 94/110094/1
Robert Varga [Wed, 31 Jan 2024 08:57:36 +0000 (09:57 +0100)]
Make Empty hashcode deterministic

All our YANG value types have a deterministic hash code, except Empty.
Fix that by assigning a hard-coded value.

Change-Id: I35d5b7a8d3bf653a2e85fc5e8fcbfe6baadc06b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd Empty.{completed,immediate}Future() 89/110089/2
Robert Varga [Tue, 30 Jan 2024 01:13:27 +0000 (02:13 +0100)]
Add Empty.{completed,immediate}Future()

A number of downstream users are using Empty as a result of a future
which should only report empty success without relying on
java.lang.Void.

Since we are not playing favorites, let's expose two versions in keeping
with Java/Guava naming conventions:
- completedFuture() is the CompletionStage
- immediateFuture() is the ListenableFuture

JIRA: YANGTOOLS-1566
Change-Id: I5897ef561f562440e5d81fa7b0711e139dc6d6ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMigrate users of ImmutableNodes 28/110028/1
Robert Varga [Sat, 27 Jan 2024 13:37:05 +0000 (14:37 +0100)]
Migrate users of ImmutableNodes

This is a simple clean up of the remaining users.

Change-Id: If5b96ad0d7fb73b98e1e5b19358d3c308004c2dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMigrate users of deprecated QNameModule methods 27/110027/3
Robert Varga [Sat, 27 Jan 2024 12:28:18 +0000 (13:28 +0100)]
Migrate users of deprecated QNameModule methods

Mass-migrate to replacement methods, reducing quite a bit of verbosity.

Change-Id: I0ae704fbc7c753e4767134840b134ad72077a37e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix deprecation marker 26/110026/1
Robert Varga [Sat, 27 Jan 2024 12:30:23 +0000 (13:30 +0100)]
Fix deprecation marker

We have the wrong version here -- 12.0.1 will never ship, it should be
13.0.1.

Change-Id: Icf2b2cbfae56885231f997b3745d9c152f7f3fe3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoUse RevisionUnion in QNameModule 42/109642/16
Robert Varga [Fri, 5 Jan 2024 14:35:28 +0000 (15:35 +0100)]
Use RevisionUnion in QNameModule

QNameModule holds an optional Revision, which is inconvenient. This
patch retrofits RevisionUnion into it.

Since we are in this area, improve instantiation api, introducing of()
and ofRevision() convenience methods and deprecate create() methods.

Since QNameModule is a WritableObject composed of XMLNamespace and
RevisionUnion, make the two also WritableObjects and delegate to them.

Change-Id: Ib5349ef324d73340b285e9634e579825e55ab95d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd QNameModule hash code tests 25/110025/1
Robert Varga [Fri, 26 Jan 2024 20:12:15 +0000 (21:12 +0100)]
Add QNameModule hash code tests

We need to ensure hash code is stable, add explicit tests for that.

Change-Id: Ibd4266c7f5f70363fc6d1e3cedbc1225d20550f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoModernize UniqueValidator 41/109941/3
Robert Varga [Tue, 23 Jan 2024 23:43:24 +0000 (00:43 +0100)]
Modernize UniqueValidator

Use local variable type inference and instanceof patterns to reduce
verbosity and explicit casts.

Change-Id: I6f8a3a8fd96037d127c091aa16a705a31775d96f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoModernize UniqueValidation a bit 43/109943/2
Robert Varga [Wed, 24 Jan 2024 00:03:17 +0000 (01:03 +0100)]
Modernize UniqueValidation a bit

Use local variable type inference and instanceof patterns to reduce
clutter.

Change-Id: I79717c6b41e6510464838d36b81158fcb26e51ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd a UniqueValues design note. 42/109942/2
Robert Varga [Tue, 23 Jan 2024 23:53:12 +0000 (00:53 +0100)]
Add a UniqueValues design note.

Change-Id: I10602a6eef1aba3b6550d747f69805daa8e4a614
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions to 13.0.1-SNAPSHOT 31/109831/1
Robert Varga [Thu, 18 Jan 2024 10:40:46 +0000 (11:40 +0100)]
Bump versions to 13.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: If46f6589ffb359b9706d0cce40299e10be7bd987
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRelease yangtools v13.0.1
jenkins-releng [Thu, 18 Jan 2024 08:11:08 +0000 (08:11 +0000)]
Release yangtools

3 months agoFix ImmutableLeaf(SetEntry)Node.toString() 89/109789/2
Robert Varga [Mon, 15 Jan 2024 22:45:54 +0000 (23:45 +0100)]
Fix ImmutableLeaf(SetEntry)Node.toString()

Allow the class identity of AbstraectNormalizedNode subclass to be
overridden, so that we can have externally-invisible class hierarchy.

Since we want to assert stable toString(), this patch also addresses
NodeWithValue.toString().

In both cases byte[] values are encoded with 'b64:' prefix followed by
base-64 encoded value.

JIRA: YANGTOOLS-1562
JIRA: YANGTOOLS-1563
Change-Id: I686eeb4769d9ebdcf21f7c11b314ccc85fe943fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix Javadoc 21 violations 51/109751/1
Robert Varga [Fri, 12 Jan 2024 00:53:49 +0000 (01:53 +0100)]
Fix Javadoc 21 violations

Java 21 seems to have a more aggresive warning set, make sure these do
not crop up where we enforce javadoc.

Change-Id: Iae3e82a11848aeb404a4058ad4cc43d8c47225f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoConvert yang-model-spi to bnd-parent 04/109704/1
Robert Varga [Thu, 11 Jan 2024 08:04:45 +0000 (09:04 +0100)]
Convert yang-model-spi to bnd-parent

This is a simplistic conversion.

Change-Id: I72bfc0b7e4d41285078e1d446848de2e8dcb6a5a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoConvert rfc7952-model-api to bnd-parent 03/109703/1
Robert Varga [Thu, 11 Jan 2024 07:58:57 +0000 (08:58 +0100)]
Convert rfc7952-model-api to bnd-parent

This is a simplistic conversion.

Change-Id: I801723ed502c0571f81a0631d9ae33f867816ebd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSilence javadoc by default 99/109699/4
Robert Varga [Wed, 10 Jan 2024 11:55:03 +0000 (12:55 +0100)]
Silence javadoc by default

Clean up build by disabling missing documentation linting or switching
enforcement on where we have zero warnings already.

Change-Id: I0da0d630b81d7090383cb608bdca56fb793e1ce4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSimplify SchemaNodeIdentifier class hierarchy 93/109693/2
Robert Varga [Wed, 10 Jan 2024 03:06:53 +0000 (04:06 +0100)]
Simplify SchemaNodeIdentifier class hierarchy

Use instanceof checks to eliminate the need for dedicated subclasses of
Absolute/Descendant.

Change-Id: I9ac512037c0930e5bc81d4ebbaa13f8b151dd8ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoCleanup mockito-configuration 98/109698/1
Robert Varga [Wed, 10 Jan 2024 12:33:11 +0000 (13:33 +0100)]
Cleanup mockito-configuration

Provide a MoreAnwers class, which exposes an THROWS_UNSTUBBED_METHOD
answer.

Also split out implementation into org.opendaylight.mockito, so that we
do not risk a class name collision.

Change-Id: I20c61b5ca7b83fba9da6fe16594c69bfc46b71ca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoModernize ArgumentsExtractorVerifier 97/109697/1
Robert Varga [Wed, 10 Jan 2024 12:23:53 +0000 (13:23 +0100)]
Modernize ArgumentsExtractorVerifier

Refactor methods to keep the flow simpler.

Change-Id: I079aae8c738ace034bf01579f998cbbfcc879675
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoUse instanceof pattern 71/109671/2
Robert Varga [Mon, 8 Jan 2024 01:37:25 +0000 (02:37 +0100)]
Use instanceof pattern

Simplify equals() implementation a bit.

Change-Id: I2c0070df979e9d81b98445b3e166a457fb851225
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoBump versions to 13.0.1-SNAPSHOT 73/109673/1
Robert Varga [Mon, 8 Jan 2024 01:39:27 +0000 (02:39 +0100)]
Bump versions to 13.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: Ie812e95612992cf7c9dbcd7fefde6dd460aaf460
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRelease yangtools v13.0.0
jenkins-releng [Sun, 7 Jan 2024 22:27:34 +0000 (22:27 +0000)]
Release yangtools

4 months agoSwitch yang-ir to bnd-parent 68/109668/3
Robert Varga [Sun, 7 Jan 2024 18:30:11 +0000 (19:30 +0100)]
Switch yang-ir to bnd-parent

This is a simplistic bundle, switch to to bnd-parent so we get control
over exported packages.

Change-Id: I77cc05d2cca5b4e4084e407ff83a2e6cb9914def
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRename YangIRSchemaSource 67/109667/3
Robert Varga [Sun, 7 Jan 2024 18:13:13 +0000 (19:13 +0100)]
Rename YangIRSchemaSource

YangIRSource is a more concise name. Also add a bit of documentation.

Change-Id: I259c41c2defd0418854e8766f730dda83e3cb4cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoCleanup dependencies 65/109665/2
Robert Varga [Sun, 7 Jan 2024 18:06:32 +0000 (19:06 +0100)]
Cleanup dependencies

The movement of {Yin,Yang}TextSource has implications on dependencies,
clean them up.

JIRA: YANGTOOLS-1561
Change-Id: I4bdc5522b8a4135352a8de494f36ecbf3a11531d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoUse plain AssertionError 66/109666/2
Robert Varga [Sun, 7 Jan 2024 18:08:27 +0000 (19:08 +0100)]
Use plain AssertionError

AssertionFailedError introduces an unneeded dependency, remove its users.

Change-Id: I66a8e812fb914f76812e01b58101ca847fe4046b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoMove YangTextSource 55/109655/10
Robert Varga [Sun, 7 Jan 2024 17:28:58 +0000 (18:28 +0100)]
Move YangTextSource

YangTextSource is something defined in RFC6020, really, expose this
construct at yang-model-api level.

JIRA: YANGTOOLS-1561
Change-Id: Ic1f0d5c37fe66d216749cfbafe0efa798bcd83f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoExpose FileYangTextSource 64/109664/4
Robert Varga [Sun, 7 Jan 2024 16:55:03 +0000 (17:55 +0100)]
Expose FileYangTextSource

Rather than having a plethora static factory methods, just expose
FileYangTextSource and use it as appropriate.

JIRA: YANGTOOLS-1561
Change-Id: I0efbd6bdcff32bb0079a5b974797320cbc3c88fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoExpose URLYangTextSource 63/109663/3
Robert Varga [Sun, 7 Jan 2024 15:51:24 +0000 (16:51 +0100)]
Expose URLYangTextSource

Rather than having a plethora of static factory methods, expose only a
few constructors.

JIRA: YANGTOOLS-1561
Change-Id: I4dee89e9243191bdf4d6bf2f1d6e5f1f71a5fd68
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoMove YinTextSource to yang.model.api.source 62/109662/4
Robert Varga [Sun, 7 Jan 2024 15:16:48 +0000 (16:16 +0100)]
Move YinTextSource to yang.model.api.source

YinTextSource is something defined in RFC6020, really, expose this
construct at yang-model-api level.

JIRA: YANGTOOLS-1561
Change-Id: Icbfa6a96a11090031c95595da14e92b888f06f23
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoExpose FileYinTextSource 61/109661/4
Robert Varga [Sun, 7 Jan 2024 15:00:22 +0000 (16:00 +0100)]
Expose FileYinTextSource

Rather than having static factory methods, expose FileYinTextSource.

JIRA: YANGTOOLS-1561
Change-Id: I02399316cb1d9f009f299abffbf1c31cf666e418
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoExpose URLYinTextSource 60/109660/2
Robert Varga [Sun, 7 Jan 2024 14:49:59 +0000 (15:49 +0100)]
Expose URLYinTextSource

Eliminate YinTextSource static methods in favor of exposing
URLYinTextSource.

JIRA: YANGTOOLS-1561
Change-Id: I444478a417988f4532310f52d1e73bed236932e8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoExpose DelegatedYinTextSource 59/109659/3
Robert Varga [Sun, 7 Jan 2024 14:37:23 +0000 (15:37 +0100)]
Expose DelegatedYinTextSource

Eliminate YinTextSource static methods in favor of making
DelegatedYinTextSource visible.

JIRA: YANGTOOLS-1561
Change-Id: I77b5223facb3de7ed216fd556ae0bd9d95fb6927
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoExpose DelegatedYangTextSource 58/109658/2
Robert Varga [Sun, 7 Jan 2024 14:13:40 +0000 (15:13 +0100)]
Expose DelegatedYangTextSource

Eliminate YangTextSource static methods in favor of making
DelegatedYangTextSource visible. This also eliminates the slew of
possibilitiess down to the bare bones -- users can cope with the trivial
conversions from ByteSource and file name.

JIRA: YANGTOOLS-1561
Change-Id: I2321e9d936489fefe059399a750393b76730e297
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoBump versions to 13.0.0-SNAPSHOT 57/109657/2
Robert Varga [Sun, 7 Jan 2024 13:38:19 +0000 (14:38 +0100)]
Bump versions to 13.0.0-SNAPSHOT

This starts the next major development iteration.

Change-Id: Ib7947413210db54a81f298caee9716800c504c84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRehost SourceIdentifier methods 56/109656/1
Robert Varga [Sun, 7 Jan 2024 12:46:51 +0000 (13:46 +0100)]
Rehost SourceIdentifier methods

SourceIdentifier is aware of .yang, expand its capabilities to also
parse file names to extract revision and handle .yin.

JIRA: YANGTOOLS-XXX
Change-Id: I5c41707677a9b8b75d81987f740a48162e2c8689
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoExpose NotRevision 51/109651/2
Robert Varga [Sat, 6 Jan 2024 01:45:38 +0000 (02:45 +0100)]
Expose NotRevision

Having RevisionUnion.none() exposing a type-safe object is useful.
Expose NotRevision and improve the test suite.

Change-Id: I0217ade57c73c65d6ce903c07b696246881aec4e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoMigrate YangVersionTest 50/109650/1
Robert Varga [Sat, 6 Jan 2024 00:53:22 +0000 (01:53 +0100)]
Migrate YangVersionTest

Use non-deprecated methods and upgrade the deprecation.

Change-Id: Ia9875471fd3bdfed1586319af317d57ca35ca9b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoConvert yang-model-api to bnd-parent 46/109646/2
Robert Varga [Fri, 5 Jan 2024 17:57:49 +0000 (18:57 +0100)]
Convert yang-model-api to bnd-parent

Modernize packaging and embrace the wonderful world of
explicitly-controlled exports.

Change-Id: Ied805ae32dcb72ba501e29c0733007a4407cb9c1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoClean up yang-model-api mocking 45/109645/2
Robert Varga [Fri, 5 Jan 2024 17:32:06 +0000 (18:32 +0100)]
Clean up yang-model-api mocking

Use mockito-configuration and MockitoExtension to be really crisp about
mocking.

Change-Id: I9102c75f15ef7cd114f656d28c94c92c54e4bd60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoBump versions to 12.0.1-SNAPSHOT 47/109647/1
Robert Varga [Fri, 5 Jan 2024 19:41:20 +0000 (20:41 +0100)]
Bump versions to 12.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: I7736a158ad4ae7111708045c990a09d9921f4b24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRelease yangtools v12.0.0
jenkins-releng [Fri, 5 Jan 2024 18:15:14 +0000 (18:15 +0000)]
Release yangtools

4 months agoAdd BuildSpecification 26/109626/15
Robert Varga [Thu, 4 Jan 2024 09:21:34 +0000 (10:21 +0100)]
Add BuildSpecification

A BuildSpecification is the set of information we want to build,
mirroring YangLibModuleSet to some degree, but actually captures our
workflows, i.e. our ability to have multiple implemented revisions of
the same module.

This patch just adds it as a pivot, adjusting yang-parser-spi
dependencies accordingly.

JIRA: YANGTOOLS-1341
Change-Id: I3b3f1569fd4e8251cbac71f5036e6354b8fac942
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoGuard against empty YangInstanceIdentifier values 67/104867/6
Robert Varga [Mon, 13 Mar 2023 22:57:42 +0000 (23:57 +0100)]
Guard against empty YangInstanceIdentifier values

Empty YangInstanceIdentifier should never be used as a value. Check this
invariant.

JIRA: YANGTOOLS-1494
Change-Id: I3763cb45cb0131a9cbc25aaef65673a08f6dc470
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAdd RevisionUnion 23/109623/9
Robert Varga [Thu, 4 Jan 2024 05:04:50 +0000 (06:04 +0100)]
Add RevisionUnion

The intrinsic nullness of Revision is quite problematic, especially when
we are interfacing the world of ietf-yang-library.

Introduce RevisionUnion, which models the ietf-yang-library union of a
revision-identifier and an empty string.

JIRA: YANGTOOLS-918
Change-Id: I2641eba8f27d71f750079b2713474e07393fddf3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoMove YangIRSchemaSource 29/109629/13
Robert Varga [Thu, 4 Jan 2024 15:52:06 +0000 (16:52 +0100)]
Move YangIRSchemaSource

Let's call this model.spi.source.YangIRSource and clean up its
interface.

As this brings things closer to where they should be, we can now use
StatementSourceException to unify the layout of our error messages and
have TextStatementReference a readily-available implementation.

Reactor is updated to recognize StatementSourceException instead of
SourceExceptions. This has the benefit of allowing us to disconnect
InferenceException from SourceException.

JIRA: YANGTOOLS-1150
Change-Id: I8b43ada04065c5183e599d48a84912a36aa6e54b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAdd serialization proxy for Revision 39/109639/2
Robert Varga [Fri, 5 Jan 2024 12:19:10 +0000 (13:19 +0100)]
Add serialization proxy for Revision

As part of the yang.common.Revision redesign, we need to allow for a
migration strategy. This introduces RUv1, which acts as a serialization
proxy for a nullable String.

JIRA: YANGTOOLS-918
Change-Id: I3658df0364b86ca0739f1a5889dd364fa42675f1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoDisconnect InferenceException from SourceException 38/109638/2
Robert Varga [Thu, 4 Jan 2024 19:45:47 +0000 (20:45 +0100)]
Disconnect InferenceException from SourceException

These two exceptions indicate different conditions, split them up to
make sure the class hierarchy prevents confusing the two.

JIRA: YANGTOOLS-1150
Change-Id: I0313d42c009e30079ac8bf0619bc989d18c6b0a4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoUse switch expressions in PathExpressionParser 37/109637/1
Robert Varga [Thu, 4 Jan 2024 19:56:38 +0000 (20:56 +0100)]
Use switch expressions in PathExpressionParser

We have two cases of trivially switch() statements, convert them to
switch expressions.

Change-Id: If5212d5e53dc12677e4973288d7ecd80c4192f3e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRefactor ExplicitStatement 36/109636/7
Robert Varga [Thu, 4 Jan 2024 16:00:06 +0000 (17:00 +0100)]
Refactor ExplicitStatement

Rather than having a superclass, just create StatementDeclarations as a
host for the two factory methods. Implementations are completely
internal and do not leak outside of this class.

We also optimize memory footprint by using two versions of each class --
one storing file/line as ints, the other one as shorts. This ends up
saving a few bytes of memory.

Eliminate the InFile specialization, as it is not used anywhere really.
Also renale atPosition() to inText() to more closely align naming.

JIRA: YANGTOOLS-1150
Change-Id: Ib5a20e45f645f00fac8d1d27c48dd4dcab16fb17
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAdd StatementDeclaration 32/109632/8
Robert Varga [Thu, 4 Jan 2024 15:41:46 +0000 (16:41 +0100)]
Add StatementDeclaration

We have only StatementInText capturing
StatementSourceReference+DeclarationReference. Add an explicit class to
hold this combination at model.api.meta level.

Also pull in the implementation of toHumanReadable() and add the
appropriate hooks.

JIRA: YANGTOOLS-1150
Change-Id: Ia6685a1a8d0d48ad12d223eefada2a2c527cb944
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRemove an explicit cast 31/109631/3
Robert Varga [Thu, 4 Jan 2024 11:51:41 +0000 (12:51 +0100)]
Remove an explicit cast

Use an instanceof pattern instead.

Change-Id: I4a8dcf3ba43fbf07cf6e79b805ebf59c327914a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoMove message formatting to StatementSourceException 28/109628/2
Robert Varga [Thu, 4 Jan 2024 09:53:18 +0000 (10:53 +0100)]
Move message formatting to StatementSourceException

It would be nice to have consistent formatting relevant things -- and
SourceException already does something nice for typing message and
source together.

JIRA: YANGTOOLS-1150
Change-Id: Ib4b941fe4035edf887d9644a6b68570747b9d937
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoPrefixResolver operates on non-null 25/109625/1
Robert Varga [Thu, 4 Jan 2024 09:17:17 +0000 (10:17 +0100)]
PrefixResolver operates on non-null

The prefix cannot legally be null, annotate that.

Change-Id: Iae55e8a450a3dd70eef11932f4f9f84f73a3b85d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAdd SourceDependency.isSatisfiedBy() 24/109624/3
Robert Varga [Thu, 4 Jan 2024 03:57:07 +0000 (04:57 +0100)]
Add SourceDependency.isSatisfiedBy()

Checking SourceDependency satisfaction can easily be centralized.

JIRA: YANGTOOLS-1150
Change-Id: I783380421cbf387bbdf25e89881b62cb4fcb4db0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAssert serialized Revision size 22/109622/1
Robert Varga [Thu, 4 Jan 2024 05:05:38 +0000 (06:05 +0100)]
Assert serialized Revision size

We have a serialization test, add an assertion on how big a string is.

Change-Id: Ia7b205d8e965cb8d86813cd1c662621748ea86c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoImprove serialization defensiveness of Revision 21/109621/1
Robert Varga [Thu, 4 Jan 2024 03:59:52 +0000 (04:59 +0100)]
Improve serialization defensiveness of Revision

Revision should never get serialized, hence it cannot be read in.

Change-Id: Icdc377ddf617e45973522d6ec237ece2b9c01ce9

4 months agoAdd @java.io.Serial 20/109620/1
Robert Varga [Thu, 4 Jan 2024 03:58:26 +0000 (04:58 +0100)]
Add @java.io.Serial

Annotate serialization field.

Change-Id: I24d9a8f19de3c39d49c68bb10a1a9b06d01b25b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoEliminate YangModelDependencyInfo 17/109617/6
Robert Varga [Wed, 3 Jan 2024 20:54:34 +0000 (21:54 +0100)]
Eliminate YangModelDependencyInfo

ModuleImport is a completely different concept to what we want to
express.

We already have SourceIdentifier, which matches the fields, but
unfortunately it has slightly different co-notations -- for a dependency
a missing revision says it is a wildcard.

We therefore create a dedicated construct, SourceDependency, which
really is a model.api.source contract.

This clarifies a lot of details about SourceInfo and DependencyResolver,
leading to complete elimination of YangModelDependencyInfo, making
DependencyResolve work on SourceInfo.

The extraction logic is hosted in YangIRSourceInfoExtractor, but we
expect it to mvoe to YangIRSchemaSource, once we have dealt with the
code structors within yang-parser-rfc7950.

JIRA: YANGTOOLS-1150
Change-Id: I913a03d2b2486e566d06f11b7f5f0d496f30c98f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoClean up YangModelDependencyInfo 96/109596/2
Robert Varga [Wed, 3 Jan 2024 20:43:53 +0000 (21:43 +0100)]
Clean up YangModelDependencyInfo

Bring the two subclasses to the front of the file and annotate returns,
enforcing non-null as appropriate.

JIRA: YANGTOOLS-1150
Change-Id: Ic33c52d4d54de03243e6eb9ad1d1df9a96d5718c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoClean up dependency declarations 95/109595/3
Robert Varga [Wed, 3 Jan 2024 19:20:03 +0000 (20:20 +0100)]
Clean up dependency declarations

Code movement we have made allows us to clean up dependencies. This
patch does that.

Change-Id: Ia01ead4410a421e0b1c0e8fe7d89377dc622720d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoImplement SourceInfo extraction 94/109594/2
Robert Varga [Wed, 3 Jan 2024 18:10:09 +0000 (19:10 +0100)]
Implement SourceInfo extraction

Create SourceInfo extractor and use it in YangModelDependencyInfo.

JIRA: YANGTOOLS-1150
Change-Id: I11a8912cd2b0abb05c0f6ee5ff0f3bc87ebe3947
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoClean up DataTreeCandidateNodesTest 86/109586/2
Robert Varga [Tue, 2 Jan 2024 18:43:58 +0000 (19:43 +0100)]
Clean up DataTreeCandidateNodesTest

Use MockitoExtension instead of explicit mocks. Also pull in
ImmutableNodes to ditch mocking of NormalizedNodes.

Change-Id: Iea956a411bce741fd7ae39b0d42621c166441ee2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoSeal YangModelDependencyInfo 93/109593/2
Robert Varga [Wed, 3 Jan 2024 18:02:16 +0000 (19:02 +0100)]
Seal YangModelDependencyInfo

We have two implementations, both of which are internal. Seal it.

Change-Id: Iacc9b5c39eba8fb7098d0596fdff08714bc5e170
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAdd SchemaSourceInfo 76/109576/32
Robert Varga [Tue, 2 Jan 2024 19:01:02 +0000 (20:01 +0100)]
Add SchemaSourceInfo

We typically need to organize SchemaSourceRepresentations in some way
and make consistency inferences against their linkage.

The RFCSs do not specifically call this out, but the information is kept
at the top of the YANG file, so that even a simple text parser can find
it quickly.

Our YANG text processing pipeline has this information available
whenever we need to build a YangModelDependencyInfo -- which is an
optional operation, but the implementation only needs IRSchemaSource.

This patch introduces SchemaSourceInfo, which is a RFC-based opinionated
version YangModelDependencyInfo.

JIRA: YANGTOOLS-1150
Change-Id: I5043f2be3138c6cf599cb8ca29c5bfb0c829625e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoMigrate tests to use node.spi.ImmutableNodes 91/109591/3
Robert Varga [Wed, 3 Jan 2024 14:36:39 +0000 (15:36 +0100)]
Migrate tests to use node.spi.ImmutableNodes

We have a few stragglers, migrate them.

JIRA: YANGTOOLS-1259
Change-Id: Ie21d13359c7ec8d4b10f3ca4193460c478acefc3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoSchemaSourceException should carry SourceIdentifier 81/109581/15
Robert Varga [Tue, 2 Jan 2024 05:37:25 +0000 (06:37 +0100)]
SchemaSourceException should carry SourceIdentifier

We have two classes that already do this, codify this fact.

JIRA: YANGTOOLS-1150
Change-Id: I63bb778b21a063346bfa432734bc60fbb0bc1560
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAdd ImmutableNode.newXYXBuilder() methods 70/109570/6
Robert Varga [Mon, 1 Jan 2024 14:42:39 +0000 (15:42 +0100)]
Add ImmutableNode.newXYXBuilder() methods

Add convenience methods forwarding to BuilderFactory and migrate most
users of deprecated constructs.

JIRA: YANGTOOLS-1259
Change-Id: I78451bca62503f87422b285c48b5167b6819806a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAdd StatementSourceException 82/109582/13
Robert Varga [Tue, 2 Jan 2024 05:38:15 +0000 (06:38 +0100)]
Add StatementSourceException

There is a missing link between in model.api.meta, which is an exception
that carries a StatementSourceReference where it occurred.

JIRA: YANGTOOLS-1150
Change-Id: I75c08b90e049b620ba532163694102ef94bbd5a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoPromote SchemaSourceRepresentation 85/109585/11
Robert Varga [Tue, 2 Jan 2024 09:04:51 +0000 (10:04 +0100)]
Promote SchemaSourceRepresentation

SchemaSourceRepresentation is an extensible framework for identifying
and working with sources of YANG schema, which eventually can become
yang.model.api constructs.

SchemaSourceRepresentation and its two immediate specializations are
landing in yang.mode.api.source, the actual implementations in
yang.model.spi.source.

JIRA: YANGTOOLS-1150
Change-Id: I10d0b3afd29f6b96b98ea8ffca0ca1c0b8ec44f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoDo not provide SourceIdentifiers from extensions 84/109584/3
Robert Varga [Tue, 2 Jan 2024 08:33:14 +0000 (09:33 +0100)]
Do not provide SourceIdentifiers from extensions

These constants are artificially holding down yang-repo-api and are not
used anywhere. remove them and clean up dependencies.

JIRA: YANGTOOLS-1150
Change-Id: I7a7b3cb410e815257bd8949ba2a948a39512551d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoPromote StatementSourceReference to model.api.meta 80/109580/4
Robert Varga [Tue, 2 Jan 2024 04:57:08 +0000 (05:57 +0100)]
Promote StatementSourceReference to model.api.meta

This class simply captures a few model.api.meta constructs, host it
where its brethren are.

JIRA: YANGTOOLS-1150
Change-Id: I8cd75e3c40ebb05dc7377b09fc9b282f014fd6dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRemove EffectiveModelContext{Listener,Provider} 75/109575/5
Robert Varga [Mon, 1 Jan 2024 19:48:07 +0000 (20:48 +0100)]
Remove EffectiveModelContext{Listener,Provider}

These are useless things that introduce verbosity.

At the end of the day, EffectiveModelContextProvider is someone who has

  EffectiveModelContext modelContext()

method -- which is but an idiom.

If we need to throw in a source of ISEs and callbacks, we are modeling
something much different -- better expressed explicitly where needed.

Change-Id: I6b1c11b01a0656a6a373e0d9b940607ee7a20aa0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoModernize ArgumentContextUtils 79/109579/4
Robert Varga [Tue, 2 Jan 2024 02:46:21 +0000 (03:46 +0100)]
Modernize ArgumentContextUtils

Use new language features:
- switch expression for YangVersion parsing
- instanceof patterns for type dispatch
- arrow cases for confiment
- multiline literal for simpler maintenance

Change-Id: Id23bf974f61b3e31abe0191e47192458a43e61ca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoMigrate YT1417Test 73/109473/1
Robert Varga [Fri, 29 Dec 2023 07:38:55 +0000 (08:38 +0100)]
Migrate YT1417Test

We have simple interactions here, migrate them to new methods.

JIRA: YANGTOOLS-1529
Change-Id: Ic2ad8122a61690c1ad22a7ef9484a4ea267a0fce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoMigrate ImmutableNodes users 70/109470/1
Robert Varga [Fri, 29 Dec 2023 07:02:00 +0000 (08:02 +0100)]
Migrate ImmutableNodes users

This is a first pass on ImmutableNodes users, migrating them from
yang-data-impl to yang-data-spi version of this class.

JIRA: YANGTOOLS-1529
Change-Id: I7add26830e008f33f281bb1ec065f1f855d1eb55
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoClean up TypeDefinitionAwareCodec 69/109469/1
Robert Varga [Fri, 29 Dec 2023 06:54:22 +0000 (07:54 +0100)]
Clean up TypeDefinitionAwareCodec

Representation class should be the first argument and we should always
require a TypeDefinition.

Change-Id: I1bb1b40de807cd36c2622c8966ab9c4db161f8f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoIntroduce {LeafSet,Map}Node.Builder 52/109452/5
Robert Varga [Fri, 29 Dec 2023 00:13:05 +0000 (01:13 +0100)]
Introduce {LeafSet,Map}Node.Builder

Having an intermediate interface holding common bits between
{System,User}LeafSetNode.Builder is useful. This patch introduces a
sealed class to capture those bits.

JIRA: YANGTOOLS-1259
Change-Id: Ie1aba04a42308cf22054936e12a041ca90888c6f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoPromote ImmutableNodes to yang-data-spi 86/104786/6
Robert Varga [Thu, 28 Dec 2023 12:47:10 +0000 (13:47 +0100)]
Promote ImmutableNodes to yang-data-spi

Immutable implementations of NormalizedNodes are generally useful for
basic operation of other NormalizedNode implementations -- for example
in the case of a lazily-materialized NormalizeNode.

Move Immutable*NodeBuilders to data.spi.node.impl, hiding them from
outside world and splitting out the actual implementations.

Builders are available indirectly through
data.spi.node.ImmutableNodes.builderFactory(), which centralizes access
and allows us to apply globally-configurable policy to builders (in a
future patch).

yang.data.impl.schema.{Builders,ImmutableNodes} are deprecated for
removal.

JIRA: YANGTOOLS-1259
Change-Id: I9eaaebcde5ce1b61e117ac712276d9288249b51a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoSeal NormalizedNode hierarchy 06/109406/13
Robert Varga [Fri, 22 Dec 2023 15:51:48 +0000 (16:51 +0100)]
Seal NormalizedNode hierarchy

This patch ensures that all of NormalizedNode interface hierarchy is
sealed, so users can rely on instanceof exhaustiveness.

As a side-effect of this change, we promote
node.spi.AbstractNormalizedNode into the API package and create a mirror
class hierarchy around it.

This hierarchy is then extende by the immutable implementations. This
adds a bit of code duplication, but it also makes it very clear what the
expectations are.

We have flushed out a couple of bugs in the process -- like
LeafSetEntryNode not protecting byte[] children.

JIRA: YANGTOOLS-1259
Change-Id: I0764278cff74a482c74381e6b5e4787ffc3f87e1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRemove unused suppression 41/109441/1
Robert Varga [Thu, 28 Dec 2023 11:44:38 +0000 (12:44 +0100)]
Remove unused suppression

Since NormalizedNode.Builder is not generic, we no longer need this
suppression.

JIRA: YANGTOOLS-1259
Change-Id: Ia253daa1ea4c29db12f93ad5a2247db4352b2f07
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRedirect Builders through ImmutableNodes' builder factory 10/109410/6
Robert Varga [Sat, 23 Dec 2023 01:09:21 +0000 (02:09 +0100)]
Redirect Builders through ImmutableNodes' builder factory

Now that we have an intermediate interface for creating builders, we
want to funnel all calls through it.

This disconnects Builders from the actual implementations.

JIRA: YANGTOOLS-1259
Change-Id: Ibc7dc9dc6de9872c1f95e25a3efd2dae50e73d08
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoBump odlparent to 13.0.10 90/109390/2
Robert Varga [Mon, 18 Dec 2023 15:01:13 +0000 (16:01 +0100)]
Bump odlparent to 13.0.10

Pick up latest upgrades.

Change-Id: I3748f701c67f6b750ab0eb08d0005b1138d63ef4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoPromote MandatorLeafEnforcer 11/109411/3
Robert Varga [Sat, 23 Dec 2023 02:40:05 +0000 (03:40 +0100)]
Promote MandatorLeafEnforcer

This is a very useful utility, promote it to data.spi.node, so it is
easily accessible.

JIRA: YANGTOOLS-980
Change-Id: I90c1320b5e3aa8fda19c50e3aeefde493da01341
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoAdd NormalizedNode.BuilderFactory 05/109405/11
Robert Varga [Fri, 22 Dec 2023 01:18:51 +0000 (02:18 +0100)]
Add NormalizedNode.BuilderFactory

Add a centralized interface for creating all know builder types. This
allows us to decouple most call sides from Builders/ImmutableNodes,
directly tying into a provider.

This decoupling can be used to further promote constructs, as their
dependency on ImmutableNodes/Builders can be indirected through this
factory.

JIRA: YANGTOOLS-1259
Change-Id: Ic68d84501b1d0e8ad3110ae8f1ece63c25c59ec1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoPromote InterningLeafSetNodeBuilder 08/109408/1
Robert Varga [Fri, 22 Dec 2023 23:34:06 +0000 (00:34 +0100)]
Promote InterningLeafSetNodeBuilder

This is a useful utility, promote it to data.spi.node, integrating
LeafsetEntryInterner.

JIRA: YANGTOOLS-980
Change-Id: Idd49b9e85fc96d9fb9d80541ce720efb92466225
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoPromote InterningLeafNodeBuilder 07/109407/1
Robert Varga [Fri, 22 Dec 2023 22:50:47 +0000 (23:50 +0100)]
Promote InterningLeafNodeBuilder

This is a useful utility, promote it to data.spi.node.

JIRA: YANGTOOLS-980
Change-Id: Id96fc4281fb39e821c8ab1e0a1132f615215a66a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoIntroduce NormalizedNode.Builder interfaces 99/109399/7
Robert Varga [Thu, 21 Dec 2023 11:58:11 +0000 (12:58 +0100)]
Introduce NormalizedNode.Builder interfaces

Each valid end-user specialization get a Builder interface, which is
then implemented by a immutable builder.

The hierarchy starts at NormalizedNode.Builder and crosses to the legacy
NormalizedNodeBuilder, ending with, for example, ContainerNode.Builder.

This builder hierarchy allows is to improve Builders API accuracy -- and
that accuracy in turn allows us to disconnect
InterningLeaf(Set)NodeBuilder from the immutable hierarchy, becoming
just forwarding implementations of Leaf(Set)Node.Builder.

JIRA: YANGTOOLS-1259
Change-Id: I8dd84914e7aef66619f6a8dfde9aa76b8aec6538
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoRemove NormalizedNode.getIdentifier() 04/109404/2
Robert Varga [Thu, 21 Dec 2023 22:13:03 +0000 (23:13 +0100)]
Remove NormalizedNode.getIdentifier()

This method has been deprecated for removal, remove it now.

JIRA: YANGTOOLS-1559
Change-Id: Ia8f839c0daa60fc64ce20084833f3516869b02a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 months agoClean up DefaultYangParser 98/109398/1
Robert Varga [Thu, 21 Dec 2023 10:54:44 +0000 (11:54 +0100)]
Clean up DefaultYangParser

- remove superfluous @NonNull
- use ImmutableSet for REPRESENTATIONS
- use instanceof patterns

Change-Id: Ifd7a0da2446d2ae7d826cff92079b3ab426c24ef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>