yangtools.git
9 days agoBump versions to 13.0.5-SNAPSHOT 40/111440/1 master
Robert Varga [Wed, 17 Apr 2024 14:34:50 +0000 (16:34 +0200)]
Bump versions to 13.0.5-SNAPSHOT

This starts the next development iteration.

Change-Id: Ia43d33c287acf9c46301ecb2a131ac0f782366c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 days agoRelease yangtools v13.0.4
jenkins-releng [Wed, 17 Apr 2024 11:50:58 +0000 (11:50 +0000)]
Release yangtools

9 days agoFix DependencyResolver 34/111434/3
Robert Varga [Tue, 16 Apr 2024 14:03:32 +0000 (16:03 +0200)]
Fix DependencyResolver

We have a problem with submodules: a submodule cannot be resolved until
its belongs-to module is resolved -- but a module cannot be resolved
until its include submodules are resolved.

Fix this by partially restoring previous logic -- i.e. we consider
submodules resolved without considering belongs-to. We then add a
separate pass to invalidate resolved modules.

JIRA: YANGTOOLS-1572
Change-Id: I3b54912fe0b9ed86b98037b0ce4551a021663199
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoHide DependencyResolverTest methods 33/111433/1
Robert Varga [Tue, 16 Apr 2024 13:23:24 +0000 (15:23 +0200)]
Hide DependencyResolverTest methods

The methods are needlessly public, hide them.

Change-Id: I00d9715948fbc3832acc4fb73e20aee0fb4983b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
11 days agoBump versions to 13.0.4-SNAPSHOT 98/111398/1
Robert Varga [Mon, 15 Apr 2024 15:20:19 +0000 (17:20 +0200)]
Bump versions to 13.0.4-SNAPSHOT

This starts the next development iteration.

Change-Id: Id7dcb8271faef8d6d4a90586b8a4dcc91569e1ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
11 days agoRelease yangtools v13.0.3
jenkins-releng [Mon, 15 Apr 2024 12:38:14 +0000 (12:38 +0000)]
Release yangtools

11 days agoBump odlparent to 13.1.1 42/110442/9
Robert Varga [Sun, 3 Mar 2024 06:22:41 +0000 (07:22 +0100)]
Bump odlparent to 13.1.1

Pick up improments from upstream.

Change-Id: I8f43c3f6da7abea981712197cd0e99d2f3123b6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 days agoDitch logback from yang-parser-rfc7950 tests 86/111386/1
Robert Varga [Sun, 14 Apr 2024 20:43:39 +0000 (22:43 +0200)]
Ditch logback from yang-parser-rfc7950 tests

Use slf4j-simple, as that is what we get by default. Also prevents a
warning about multiple providers being present.

Change-Id: I29d77f7ca1094cd773650c711167e1d42dcbf5ca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDefeat potential singleton pollution attacks 48/111348/1
Robert Varga [Wed, 10 Apr 2024 13:50:16 +0000 (15:50 +0200)]
Defeat potential singleton pollution attacks

yang.common.Empty is a Serializable, which has no state beside its class
hierarchy. It therefore lends itself to having a singleton value object
-- except SpotBugs flags this as a violation MSC07-J rule in SEI CERT
Oracle Coding Standard for Java.

Digging into this, the readResolve() guard could be defeated via
hand-crafted serialization -- and thus could in theory have more than
once instance. Doing so would allow to have two Empty instances which
have the same Class, but do not compare as equal.

This patch erases that possibility, fixing a possibility of the error.

Also update documentation a bit to remove the word 'singleton', so users
are not tempted to use '==' for comparison -- which is already a bad
idea anyway.

Change-Id: Ibccd2909790e7a46d002d80f7b36280ff27fb724
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoModernize mocking in yang-data-api 18/111318/4
Robert Varga [Mon, 8 Apr 2024 01:10:31 +0000 (03:10 +0200)]
Modernize mocking in yang-data-api

We are testing utility classes with incomplete mocks. Enforce complete
mocking and drop FIXMEs for improvement.

Change-Id: Ifa17b12d5c6d801705b11e3685f53ec1c937ceab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix a requires warning 17/111317/1
Robert Varga [Mon, 8 Apr 2024 01:33:41 +0000 (03:33 +0200)]
Fix a requires warning

We are using Immutables for the default implementation, which leaks the
dependency. We should therefore import it transitively.

Change-Id: Ib9493744b0617c2ee7193cc3b6ff692e59ec6b57
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoAllow emission of operation input/output 79/111279/5
Robert Varga [Fri, 5 Apr 2024 09:49:23 +0000 (11:49 +0200)]
Allow emission of operation input/output

Both XML and JSON codecs should be in a place where they can emit
RPC/action input/outputs -- except NormalizedNodeStreamWriterStack
cannot initialize there.

Rework NormalizedNodeStreamWriterStack internal tracking to work on
EffectiveStatements and lift this restriction.

JIRA: YANGTOOLS-1570
Change-Id: If45bb096ee30cc35bf2a40ec26e12217f71ca06c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoRename JSONInstanceIdentifierCodec 49/111249/1
Robert Varga [Thu, 4 Apr 2024 00:49:48 +0000 (02:49 +0200)]
Rename JSONInstanceIdentifierCodec

This class is oddly named, it should be called
InstanceIdentifierJSONCodec.

Change-Id: I479475fb63e151f2756e44d62bf388d83bae01f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoDeprecate UnknownTypeDefinition 48/111248/1
Robert Varga [Thu, 4 Apr 2024 00:36:03 +0000 (02:36 +0200)]
Deprecate UnknownTypeDefinition

This is just a stray API element, causing problems to downstreams of
model.api.type. Deprecate it for removal.

Change-Id: Ib8ac000ca8fbb533483bda5f3e7430db52d3a327
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoAdd JSONValue and JSONCodec.unparseValue() 11/111211/4
Robert Varga [Tue, 2 Apr 2024 17:54:08 +0000 (19:54 +0200)]
Add JSONValue and JSONCodec.unparseValue()

RESTCONF use case requires serializing values using JSON encoding --
without having a document ready.

Introduce JSONValue to encapsulate what sort of values we can have along
with JSONCodec.unparseValue() -- which produces such values.

JIRA: YANGTOOLS-1569
Change-Id: I398af058b5c017803a9dc4c61d3f7cfbc45cca5b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 weeks agoDisconnect JSONCodec from JsonWriter 74/111174/4
Robert Varga [Tue, 2 Apr 2024 08:49:01 +0000 (10:49 +0200)]
Disconnect JSONCodec from JsonWriter

We have a use case where we would like to JSON-encode values without a
JsonWriter. Introduce JSONValueWriter to enable the values to be
intercepted.

JIRA: YANGTOOLS-1569
Change-Id: I8cabe490a78effb78d6d4bfaf0bb62238bd1b809
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 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>
3 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>
3 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>
6 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>
6 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>
6 weeks agoRelease yangtools v13.0.2
jenkins-releng [Tue, 12 Mar 2024 10:39:59 +0000 (10:39 +0000)]
Release yangtools

7 weeks 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>
8 weeks 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
3 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>
3 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>
3 months agoRelease yangtools v13.0.0
jenkins-releng [Sun, 7 Jan 2024 22:27:34 +0000 (22:27 +0000)]
Release yangtools

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 months agoRelease yangtools v12.0.0
jenkins-releng [Fri, 5 Jan 2024 18:15:14 +0000 (18:15 +0000)]
Release yangtools

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>