yangtools.git
12 months agoEliminate rfc8528-data-util 18/106018/2
Robert Varga [Wed, 17 May 2023 17:49:06 +0000 (19:49 +0200)]
Eliminate rfc8528-data-util

Move the remaining classes to yang-data-util, completing the baseline
integration.

JIRA: YANGTOOLS-1172
Change-Id: I946b41a6ff200576578cce25386646433e2e8a8d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoMove MountPointNormalizedNodeWriter 17/106017/2
Robert Varga [Wed, 17 May 2023 17:28:20 +0000 (19:28 +0200)]
Move MountPointNormalizedNodeWriter

Mount points are inherently integrated into NormalizedNodeWriter,
co-locate it with its baseline interface.

JIRA: YANGTOOLS-1172
Change-Id: I0c99bcde7c9ec086b9b01987b17ea4206680a5fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoDocument NormalizedTree 16/106016/2
Robert Varga [Wed, 17 May 2023 17:13:52 +0000 (19:13 +0200)]
Document NormalizedTree

This interface lacks javadocs, add rudimentary documentation.

JIRA: YANGTOOLS-1172
Change-Id: Ib5fec7455ab447762263d0e7069433026987e1b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoRemove MountPointIdentifier 15/106015/3
Robert Varga [Wed, 17 May 2023 16:17:45 +0000 (18:17 +0200)]
Remove MountPointIdentifier

Remove MountPointIdentifier as the last remnant of rfc8528-data-api.
This forces an adjustment to yang-data-codec-binfmt, which can no longer
read this PathArgument.

It also allows us to seal YangInstanceIdentifier.PathArgument, not
allowing any external implementations of it.

JIRA: YANGTOOLS-1172
Change-Id: Ibdbb5d2eb9d63f3d0e8a95065e8124ce6818a7af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agocreateTestContainer() can be static 14/106014/1
Robert Varga [Wed, 17 May 2023 16:39:38 +0000 (18:39 +0200)]
createTestContainer() can be static

This is minor note from Eclipse, fix iit.

Change-Id: Ia96b1ccf2ea6d7c605b2f1e62660521c23055f68
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoEliminate MountPointNode 08/106008/5
Robert Varga [Tue, 16 May 2023 23:36:25 +0000 (01:36 +0200)]
Eliminate MountPointNode

Switch mount points from being in-line to being out-of-line just as
NormalizedMetadata is. This allows users to explicitly manage the
lifecycle -- preventing accidental leaks to NormalizedNode hierarchy.

This introduces NormalizedTree as a top-level construct, which holds
NormalizedNode, NormalizedMetadata and NormalizedMountpoints.

JIRA: YANGTOOLS-1172
Change-Id: I523afc166c5532be8db928a3b3288cac266ed3e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoReduce MountPointIdentifier proliferation 11/106011/1
Robert Varga [Wed, 17 May 2023 11:34:31 +0000 (13:34 +0200)]
Reduce MountPointIdentifier proliferation

Use MountPointLabel instead of MountPointIdentifier.

JIRA: YANGTOOLS-1172
Change-Id: I1f63053815cedb2cb781f206ff63f815ce56f478
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoSeal ImmutableNormalizedMetadata 07/106007/3
Robert Varga [Tue, 16 May 2023 23:27:12 +0000 (01:27 +0200)]
Seal ImmutableNormalizedMetadata

We have a single subclass, prevent other subclasses from barging in.
Also remove @Beta.

Change-Id: Ic4ce8883f2db4f02afc64ea04a3d8a6058d49e10
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoRework ExtensibleObject interface 06/106006/6
Robert Varga [Tue, 16 May 2023 22:38:58 +0000 (00:38 +0200)]
Rework ExtensibleObject interface

Exposing a simple ClassToInstanceMap() ends up being ugly from caller
perspective. Exposing simple access/enumerator methods has much better
ergonomics.

JIRA: YANGTOOLS-1509
Change-Id: I643e48ee2dabec251357fafe98d5376dc20d09c6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoRename NormalizedNodeStreamWriterExtension 05/106005/6
Robert Varga [Tue, 16 May 2023 22:01:55 +0000 (00:01 +0200)]
Rename NormalizedNodeStreamWriterExtension

Centralize the extension model in NormalizedNodeStreamWriter, shortening
names of the interfaces/classes involved. This also makes extensions
much more discoverable -- and we only have two of them :)

JIRA: YANGTOOLS-1172
Change-Id: Ie30f07e4fa618b162b38ca70652930112fcdc3cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoAdd NormalizationResult 03/106003/5
Robert Varga [Tue, 16 May 2023 19:12:49 +0000 (21:12 +0200)]
Add NormalizationResult

So far we have had only two possible results: NormalizedNode and
NormalizedMetadata. RFC8528 mount points have hidden in the
NormalizedNode hierarchy -- and we want to change that.

Doing a straighforward extension would end up stepping towards
combinatoric explosion: NormalizedNodeResult and
NormalizedNodeMetadataResult are the effect of two components, one of
which is mandatory. Adding MountPoints would result in four
combinations: data, data+metadata, data+mount, data_metadata+mount.

Rather than going that route, explicitly acknowledge we have multiple
components and concentrate them in NormalizationResult, which at this
point combines NormalizedNode and NormalizedMetadata.

On the receiver side we end up havingNormalizationResultHolder, for the
lack of a more imaginative name.

JIRA: YANGTOOLS-1172
Change-Id: Ib9866fee5223a1eb450e5d40d54d4472bae9adda
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoAdd MountPointContext.of(EffectiveModelContext) 01/106001/7
Robert Varga [Tue, 16 May 2023 18:34:15 +0000 (20:34 +0200)]
Add MountPointContext.of(EffectiveModelContext)

Rather than having a dedicated public class for the common case,
introduce a static of() method, which hides the implementation.

JIRA: YANGTOOLS-1172
Change-Id: Ib82d078c599f09f31de650aae0c096044c70847c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoEliminate YangLibraryConstants 99/105999/9
Robert Varga [Tue, 16 May 2023 17:28:55 +0000 (19:28 +0200)]
Eliminate YangLibraryConstants

RFC7950 implies integration with at least RFC7895, hence
ietf-yang-library constants are a fair game in YangConstants. Expand the
number of constants we keep and adjust users.

JIRA: YANGTOOLS-1172
Change-Id: Id32a8621b4bac8725239e3cb4d3046e3ddb06565
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoMountPointStatement should operate on MountPointLabel 96/105996/9
Robert Varga [Tue, 16 May 2023 16:55:41 +0000 (18:55 +0200)]
MountPointStatement should operate on MountPointLabel

Having an opaque QName is not exactly friendly, make sure we operate on
MountPointLabel, so it can be directly picked up.

JIRA: YANGTOOLS-1172
Change-Id: I1713c76b9919200d18b3390f085d68d9b12e4354
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoFix checkState() string 02/106002/2
Robert Varga [Tue, 16 May 2023 18:54:54 +0000 (20:54 +0200)]
Fix checkState() string

Placeholders should be %s, not {}.

Change-Id: I1e2879be989397590cee13d3905e3f1b27302c7f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoStreamWriterMountPointExtension operates on MountPointLabel 95/105995/9
Robert Varga [Tue, 16 May 2023 16:41:09 +0000 (18:41 +0200)]
StreamWriterMountPointExtension operates on MountPointLabel

Disconnect stream support from MountPointIdentifier, so that we can move
it and evolve it.

JIRA: YANGTOOLS-1172
Change-Id: I7f6a190575bf4477795c1cc079091d644f966310
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoMove MountPoint{Child,Context,ContextFactory} 94/105994/6
Robert Varga [Tue, 16 May 2023 16:27:43 +0000 (18:27 +0200)]
Move MountPoint{Child,Context,ContextFactory}

This makes a step towards re-integrating mount points by explicitly
making them know in yang-data-api. Also removes the dependency on
yang-parser-api by adding a dedicated checked exception.

JIRA: YANGTOOLS-1172
Change-Id: I5c6fa5b86d76e7fe4d3e13e1a76e70eb2f1b6177
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoTrim internal whitespace 00/106000/2
Robert Varga [Tue, 16 May 2023 17:41:34 +0000 (19:41 +0200)]
Trim internal whitespace

We have an offset of 8, we can just use 4.

Change-Id: I8d4758e8c22812bdda4415deef2d92c4e78505a4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoRemove RFC7950_YANG_LIBRARY_CAPABILITY 98/105998/3
Robert Varga [Tue, 16 May 2023 17:17:48 +0000 (19:17 +0200)]
Remove RFC7950_YANG_LIBRARY_CAPABILITY

This constant is not used anywhere, remove it.

Change-Id: I601cddd63a34c5e20687a271c3053500af4e6c04
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoDeprecate YangConstants.RFC7950_YANG_LIBRARY_CAPABILITY 97/105997/3
Robert Varga [Tue, 16 May 2023 17:15:45 +0000 (19:15 +0200)]
Deprecate YangConstants.RFC7950_YANG_LIBRARY_CAPABILITY

This capability, in proper String format is hosted in the NETCONF
project, which is its proper place. Deprecate the constatnt for removal.

Change-Id: Ibfd87395354f8a88d5e4a25229a65564530d826d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoSplit out MountPointLabel 93/105993/2
Robert Varga [Tue, 16 May 2023 15:57:29 +0000 (17:57 +0200)]
Split out MountPointLabel

MountPointIdentifier is quite heavy-handed in its tie-in with
PathArgument. Introduce a much simpler MountPointLabel, and update
MountPointContext/MountPointDefinition to operate on it.

JIRA: YANGTOOLS-1172
Change-Id: I3a9067c1cb4650dc0dcddcaee53d02d0307d1f0d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoSprinkle MPIv1 with java.io.Serial 92/105992/1
Robert Varga [Tue, 16 May 2023 15:04:03 +0000 (17:04 +0200)]
Sprinkle MPIv1 with java.io.Serial

This is a serialization proxy, make sure we annotate
serialization-related fields/methods.

JIRA: YANGTOOLS-1172
Change-Id: Ie794604b8b120176ae0291c30710c278ab995ee4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoSimplify YangLibraryConstants.ContainerName 91/105991/1
Robert Varga [Tue, 16 May 2023 15:02:13 +0000 (17:02 +0200)]
Simplify YangLibraryConstants.ContainerName

Use a switch expression instead of map lookup. Also use @Nullable return
to make users simpler.

JIRA: YANGTOOLS-1172
Change-Id: I7cda0c1b1eaa528ef2614eb0e8e1803b0ccb5839
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoAdd NormalizedNodeDataInput.readLegacyIdentifier() 79/104479/15
Robert Varga [Wed, 22 Feb 2023 14:51:28 +0000 (15:51 +0100)]
Add NormalizedNodeDataInput.readLegacyIdentifier()

This is a migration method for users for readPathArgument(), which
has an indication of the fact that the identifier would have been an
AugmentationIdentifier or a MountPointIdentifier.

JIRA: YANGTOOLS-568
Change-Id: I4f6e68d5decde9d57da9f0431d87e0d8db80a0d0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoSimplify MandatoryLeafEnforcer instantiation 73/105973/4
Robert Varga [Mon, 15 May 2023 21:14:45 +0000 (23:14 +0200)]
Simplify MandatoryLeafEnforcer instantiation

Use @Nullable return instead of optional, reducing some verbosity.

Change-Id: Iaa9e68a35be4006bff92db413ccf2174988d5fca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoClean up yang-maven-plugin dependencies 58/105958/1
Robert Varga [Mon, 15 May 2023 17:58:35 +0000 (19:58 +0200)]
Clean up yang-maven-plugin dependencies

We have quite a few warnings here -- make sure we clean them up.
Most notably yang-parser-impl is a scope=runtime dependency.

Change-Id: I44b5e8c8f79709c3fadffcbdfc42f665d29bb8c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoConvert plugin-generator-api to bnd-parent 57/105957/1
Robert Varga [Mon, 15 May 2023 17:49:17 +0000 (19:49 +0200)]
Convert plugin-generator-api to bnd-parent

This is a very simple component, convert it to use bnd-parent instead of
bundle-parent.

Change-Id: I53dcc7839ee84e6ce3a06ecdab6029f988e22a59
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoConvert dependency checking to aether 56/105956/2
Robert Varga [Mon, 15 May 2023 16:44:12 +0000 (18:44 +0200)]
Convert dependency checking to aether

maven-3.9.1 warns when we are using the RepositorySystem. Convert type
checks and remove the mocked test. This allows us to hide the
checkClasspath() method and use injected values. Also inline
getPluginTransitiveDependencies(), as it is now a single-caller thing.

JIRA: YANGTOOLS-1505
Change-Id: I9585774047b99fac557b6b92f5d51eaacfdd0af3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoRemove YangToSourcesMojo.remoteRepos 54/105954/1
Robert Varga [Mon, 15 May 2023 15:52:09 +0000 (17:52 +0200)]
Remove YangToSourcesMojo.remoteRepos

This is a shorthand and the only user already has project handy.

Change-Id: I1fd6e98c9b781f30a978dc194aacaaa25deec498
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoMove yang.skip property 33/105933/1
Robert Varga [Sat, 13 May 2023 18:33:20 +0000 (20:33 +0200)]
Move yang.skip property

Clean up order of user-visible properties vs. components.

Change-Id: I73f019f98a669b65b411af26681dc98390dc2c40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoRemove YangToSourcesMojo.parserMode 27/105927/1
Robert Varga [Sat, 13 May 2023 17:16:06 +0000 (19:16 +0200)]
Remove YangToSourcesMojo.parserMode

The parser mode is picked up from the code generators now, remove it.

Change-Id: I9ef0c93c7a7e78c5b1b04459b56257a173eea83a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoEnrich YangParserTestUtils with parseYang(String) 41/105541/7
matus.matok [Thu, 20 Apr 2023 10:13:56 +0000 (12:13 +0200)]
Enrich YangParserTestUtils with parseYang(String)

Added a new static method parseYang() to YangParserTestUtils which allows for
parsing a yang file directly from s string input. This allows for higher
flexibility as we do not need to deal with resource accessibility across
modules. Additionally, it is sometimes more convenient to prefer this new form
of input rather than the old one.

JIRA: YANGTOOLS-1483
Change-Id: I4865b73ba8770669a54dd5be167b2ca2d63f3585
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoAdd ImmediateYangTextSchemaSource 02/105802/3
Robert Varga [Wed, 3 May 2023 01:36:25 +0000 (03:36 +0200)]
Add ImmediateYangTextSchemaSource

Add ImmediateYangTextSchemaSource, which has the backing bytes readily
available. This is open for extension, making it useable in the context
of NETCONF's CachedYangTextSchemaSource.

While we are at it, we clean up how addToStringAttributes() works,
making it optional to implement it.

JIRA: YANGTOOLS-1507
Change-Id: I8a97549993a276bb419383a0d9b3eea031866d64
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoAdd explicit test for getChildArg() 45/105645/2
Robert Varga [Mon, 24 Apr 2023 11:04:00 +0000 (13:04 +0200)]
Add explicit test for getChildArg()

Make sure the method is tested to assert.

Change-Id: I3e0c3abf4b48e70fce63dd42647b4718cdcea77f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoImprove DistinctNodeContainer.getChildByArg() 08/105608/1
Robert Varga [Sun, 23 Apr 2023 06:51:50 +0000 (08:51 +0200)]
Improve DistinctNodeContainer.getChildByArg()

Improve the reported exception to include the key that was being looked
up.

Change-Id: Ica2885543d5d2c68fd84db54c57948f468f8fa2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoBump odlparent to 12.0.5 38/105538/1
Robert Varga [Thu, 20 Apr 2023 07:37:36 +0000 (09:37 +0200)]
Bump odlparent to 12.0.5

Pick up a regression fix and a few updates.

Change-Id: Ie9c8e08a130b305bc9f99e68eb881190641595c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4d122df79856358a1cc436cd4fee9bd1d29d6bf8)

13 months agoConvert yang-common-netty to bnd-parent 14/105514/4
Robert Varga [Wed, 19 Apr 2023 15:59:06 +0000 (17:59 +0200)]
Convert yang-common-netty to bnd-parent

This is a very simple bundle, convert it with minimal effort. Also adds
a package-info.

Change-Id: I2ca24a65fbed72c534d2d2f28eca327453d3173f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoFix yang-common-netty module warnings 13/105513/4
Robert Varga [Wed, 19 Apr 2023 16:05:30 +0000 (18:05 +0200)]
Fix yang-common-netty module warnings

Explicitly require netty-common and document the module.

Change-Id: I08c4762b12be7b65ce7d0088c8e842165bfb4c9f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoClean up warnings in concepts 18/105518/1
Robert Varga [Wed, 19 Apr 2023 18:05:22 +0000 (20:05 +0200)]
Clean up warnings in concepts

Fix a javadoc typo, document module-info and require checker-qual
transitively.

Change-Id: I76bf827437ca60500d142ec999dee2782f1ffe8b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoPromote FeatureSet 27/105227/14
Robert Varga [Tue, 4 Apr 2023 17:29:20 +0000 (19:29 +0200)]
Promote FeatureSet

We are using only Set.contains() to evaluate feature expressions and we
need more flexibility that that. FeatureSet already provides this
capability, but unfortunately it also implies all the Set semantics.

This patch refactors FeatureSet to be a simple class, without a tie to
Set and updates IfFeatureExpr to integrate with it.

JIRA: YANGTOOLS-1504
Change-Id: Ie719f7a3d006f2d6ed51c70604236e4105d8f8ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoBump odlparent to 12.0.4 52/105352/6
Robert Varga [Tue, 11 Apr 2023 00:26:55 +0000 (02:26 +0200)]
Bump odlparent to 12.0.4

Adopt latest updates from upstream.

Change-Id: I9dcad627cd3c0530add6ec902f5d96a90b8f45a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoMigrate users of Optional.get() 51/105351/4
Robert Varga [Sat, 8 Apr 2023 20:28:58 +0000 (22:28 +0200)]
Migrate users of Optional.get()

Optional.orElseThrow() has a more explicit name, preventing potential
confusion with Future.get() and making it clear there might be an
exception coming.

Also take the time to modernize code with local variable type inference,
instanceof patterns and similar.

Change-Id: Ifca580e0f6c652da270260dc126f79d7f32b9ff2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c5e2515ee057d1a7f63d88053a77678739356054)
(cherry picked from commit b66cbba275126b82d2951bbd812c05fb3f21a74d)

13 months agoRemove LeafRefYangSyntaxErrorException 50/105350/2
Robert Varga [Tue, 11 Apr 2023 00:03:54 +0000 (02:03 +0200)]
Remove LeafRefYangSyntaxErrorException

This exception is not used anywhere, remove it. Also update
LeafRefContextTreeBuilder to use ArrayList.

Change-Id: I89dd0f33c6418b0ce66dd7ecbf9dd7c6c6bcc16c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoUse a Multimap for keyListeners 81/105281/2
Robert Varga [Mon, 10 Apr 2023 23:52:17 +0000 (01:52 +0200)]
Use a Multimap for keyListeners

Fix a long-standing FIXME, which improves performance when there are
listeners for distinct keys. We use ArrayDeque for potentially faster
behaviour.

Change-Id: I71ddad396469a1d3623358269f385c542a2fa941
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoSimplify StmtContext generics 39/105339/2
Robert Varga [Mon, 10 Apr 2023 18:47:37 +0000 (20:47 +0200)]
Simplify StmtContext generics

We have generic signatures that hark back to when we used .class
references for namespaces. Simplify them, which makes it clear that
addContext() is just an alias to addToNs() -- and hence can be
eliminated.

Change-Id: I34637bbe913f7e23b615cfb51a7b0b69c14507db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoSimplify InferredStatementContext.hasEmptySubstatements() 38/105338/1
Robert Varga [Mon, 10 Apr 2023 18:33:27 +0000 (20:33 +0200)]
Simplify InferredStatementContext.hasEmptySubstatements()

SonarCloud is pointing out a code smell around explicit 'false',
refactor to eliminate it.

Change-Id: I7d6eb0f902d72dcdf616b48f9b02994b7280358c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoSprinkle @NonNull annotations 33/105333/2
Robert Varga [Sat, 8 Apr 2023 20:14:38 +0000 (22:14 +0200)]
Sprinkle @NonNull annotations

Contexts should always be non-null, improve a few places where we do not
make that explicit.

Change-Id: Ia11fb8e13f98c3e4c15bf0597b2191cb8553eac2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoUse instanceof pattern 32/105332/1
Robert Varga [Sat, 8 Apr 2023 19:56:30 +0000 (21:56 +0200)]
Use instanceof pattern

This removes an unnecessary cast.

Change-Id: I5fed4dbc753f7691b89fe059cbb4f89cf0fc3600
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoTighten canReuseCurrent() contract 31/105331/2
Robert Varga [Sat, 8 Apr 2023 19:40:26 +0000 (21:40 +0200)]
Tighten canReuseCurrent() contract

The we are passing a List down and that is what substatement semantics
are: adjust the method signature to use List instead of Collection.

Change-Id: Iefa694657b4540f73452f9d492744dac5da25d14
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoMove substatement ordering to yang-parser-reactor 26/105326/3
Robert Varga [Sat, 8 Apr 2023 17:49:57 +0000 (19:49 +0200)]
Move substatement ordering to yang-parser-reactor

Substatement ordering should be something reactor handles, hence move it
out to make sure StatementFactory does not have to deal with this,
making the API towards StatementFactory more consistent.

Change-Id: I9106e04c22227f054be23cf4ace492ffe416ff98
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoReuse NamespaceAccess where possible 18/105318/2
Robert Varga [Fri, 7 Apr 2023 15:20:47 +0000 (17:20 +0200)]
Reuse NamespaceAccess where possible

We have a few places where we can end up looking up NamespaceAccess for
a second time. Clean those up and also improve NamespaceAccess to expose
the underlying ParserNamespace.

Change-Id: I43e582a3c6db359d1f81819ac0445ac8b33e85bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRefactor globalOrStatementSpecific() 83/105283/1
Robert Varga [Thu, 6 Apr 2023 21:42:52 +0000 (23:42 +0200)]
Refactor globalOrStatementSpecific()

Current implementation elicits a nullness warning, which is not quite
there -- at the cost of verifyNotNull().

If we refactor checks we can actually make it more performant and
transparent. This is advanteous bacause a null parent implies current is
a GLOBAL storage -- and we therefore can just check the storage type for
STATEMENT_LOCAL.

As it turns out we can refactor the loop to make it obvious, in that we
manually check parent storage. This makes the code flow nicer and more
transparent -- there are no IDE-invisible non-null guarantees. A null
parent storage indicates GLOBAL storage, hence we can bail.

A further boon is that we can simplify the StorageType check to only
compare to STATEMENT_LOCAL and

Change-Id: I5a5b7faf312db6de7f1cebe654f18e9785f58bac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRefactor global NamespaceStorage access 82/105282/5
Robert Varga [Thu, 6 Apr 2023 20:43:45 +0000 (22:43 +0200)]
Refactor global NamespaceStorage access

There is only one way we are passing BuildGlobalContext, hence there is
no reason to indirect access through GlobalStorageAccess, as there is
only one implementation of it -- which always has the result handy.

Remove GlobalStorageAccess and introduce GlobalStorage as a
specialization of NamespaceStorage -- and pass that to
NamespaceBehaviour. This also improves coupling a bit, as there is only
a single implementation (as opposed to NamespaceStorage, which has
multiple implementations).

JIRA: YANGTOOLS-1497
Change-Id: Ica03ac855b62541ec5c52ce24044387199c75e9c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove DerivedNamespaceBehaviour 80/105280/5
Robert Varga [Thu, 6 Apr 2023 14:42:35 +0000 (16:42 +0200)]
Remove DerivedNamespaceBehaviour

DerivedNamespaceBehaviour is not used anywhere and is source of quite a
bit of head-scratching. Remove it, which allows is to solidify
NamespaceAccess to a great extent.

JIRA: YANGTOOLS-1502
Change-Id: Iba43d0f627d5df53f18e9ea4de79f0982b62d837
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoShortcut access to global NamespaceStorage 50/94650/15
Robert Varga [Thu, 6 Apr 2023 12:54:28 +0000 (14:54 +0200)]
Shortcut access to global NamespaceStorage

Most of our namespaces are stored in StorageType.GLOBAL. Accessing that
requires walking the NamespaceStorage tree completely towards its root,
which takes a lot of time.

This is highlighted by the fact that yang-parser-reactor already
performs this walk in order to find the actual behaviour, which is
stored in BuildGlobalContext -- which happens to also be the GLOBAL
NamespaceStorage object.

The result of that walk is NamespaceAccess, which is always instantiated
from a place which has immediate access to BuildGlobalContext -- either
it is BuildGlobalContext itself or it is SourceSpecificContext.

This patch introduces NamespaceBehaviour.GlobalStorageAccess, which
allows users to acquire the global NamespaceStorage and modifies
NamespaceBehaviour methods to require an instance of this interface.

NamespaceAccesss is extended to implement GlobalStorageAccess and taught
to pass itself to the backing NamespaceBehaviour.

JIRA: YANGTOOLS-1497
Change-Id: I74ac1a31176e8f3fc33875dff775965d1129391f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRefactor NamespaceBehaviourWithListeners 78/105278/4
Robert Varga [Thu, 6 Apr 2023 09:51:12 +0000 (11:51 +0200)]
Refactor NamespaceBehaviourWithListeners

There is quite a bit of confusion about what NamespaceBehaviour really
means inside yang-parser-reactor. This stems from the fact we actually
subclass NamespaceBehaviour and forward calls to a delegate in
NamespaceBehaviourWithListeners.

Refactor the class hierarchy, by renaming
NamespaceBehaviourWithListeners to NamespaceAccess, introducing explicit
access methods. These are then realized by a dedicated subclass,
BehaviourNamespaceAccess.

This provides a clear separation of concerns, also removing the need
to verify objects in ReactorStmtCtx.

JIRA: YANGTOOLS-1204
Change-Id: Ie6334e8a20359c0faf73a2150541f06f55cdd083
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove Optional from NamespaceBehaviour 75/105275/2
Robert Varga [Thu, 6 Apr 2023 11:52:05 +0000 (13:52 +0200)]
Remove Optional from NamespaceBehaviour

The criterion-based getFrom() method is unlike all others in that it
returns an Optional. Switch to returning a @Nullable.

JIRA: YANGTOOLS-1204
Change-Id: I5100f4ddac239fb8bbe8c92fa11bae1eb754db83
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRename NamespaceStorageSupport 71/105271/2
Robert Varga [Thu, 6 Apr 2023 09:34:24 +0000 (11:34 +0200)]
Rename NamespaceStorageSupport

NamespaceStorageSupport is a rather misleading name -- this actually is
an abstract implementation of NamespaceStorage. Rename it to
AbstractNamespaceStorage.

JIRA: YANGTOOLS-1500
Change-Id: I24b7bac34a116e72671d5cb447673a6b13de57ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoSplit out NamespaceStorage(Node/Type) 70/105270/6
Robert Varga [Thu, 6 Apr 2023 07:12:43 +0000 (09:12 +0200)]
Split out NamespaceStorage(Node/Type)

The connection between NamespaceBehaviour and NamespaceStorageNode is
artifically too strong. Separate NamespaceStorageNode into a top-level
class and rename it to NamespaceStorage -- which is consistent with
argument naming in behaviours.

JIRA: YANGTOOLS-1500
Change-Id: Ie3a3bcba0f5361cf8e21f5530f152457a10bdd1d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoDisconnect NamespaceBehaviour from Identifiable 69/105269/3
Robert Varga [Thu, 6 Apr 2023 06:54:30 +0000 (08:54 +0200)]
Disconnect NamespaceBehaviour from Identifiable

NamespaceBehaviour has a ParserNamespace as its identifier. This makes
it hard to look for callers a bit -- at the end of the day all code
interacting with it already knows it is a namespace. Also perform
general cleanups while we are in the area.

JIRA: YANGTOOLS-1501
Change-Id: I540ee498d106c6c3714bd08bf73f5aa3d85a5978
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove NamespaceBehaviourRegistry 68/105268/2
Robert Varga [Thu, 6 Apr 2023 06:30:22 +0000 (08:30 +0200)]
Remove NamespaceBehaviourRegistry

This interface is an unneeded indirection. Inline
getNamespaceBehaviour() into NamespaceStorageSupport and implement it as
appropriate.

JIRA: YANGTOOLS-1499
Change-Id: I48741ce53a9ff8d52d5a4c2095641002a8d74bfc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoMove NamespaceBehaviour.Registry 67/105267/3
Robert Varga [Wed, 5 Apr 2023 20:04:21 +0000 (22:04 +0200)]
Move NamespaceBehaviour.Registry

This concept is not referenced in yang-parser-spi and evolving it has
potential to reap major benefits. Rehost it as
NamespaceBehaviourRegistry pending it removal.

JIRA: YANGTOOLS-1499
Change-Id: Ib9f8aba1fc9dc757f2435c131a6abac8a8c91d48
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoDisconnect StatementSupportBundle/NamespaceBehaviour.Registry 63/105263/3
Robert Varga [Wed, 5 Apr 2023 19:42:37 +0000 (21:42 +0200)]
Disconnect StatementSupportBundle/NamespaceBehaviour.Registry

StatementSupportBundle is a very concrete class and
NamespaceBehaviour.Registry is a general interface. There is a
connection between them in that other Registry implementations are using
StatementSupportBundle -- but other than that, there is just the
self-similar binding to StatementSupportBundle.parent.

Disconnect these two classes to allow them to go their separate ways.

JIRA: YANGTOOLS-1498
Change-Id: I177b11def897f15b1be7e251d2f1712386a102f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoAdd java.io.Serial annotation 64/105264/1
Robert Varga [Wed, 5 Apr 2023 20:03:12 +0000 (22:03 +0200)]
Add java.io.Serial annotation

Exceptions or not, tying Serializable to its constructs is always good.

Change-Id: I1386a521c093e72d17b656d7aa1b3480141feca7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoAdd ReactorStmtCtx.getStorageNodeType() 62/105262/2
Robert Varga [Wed, 5 Apr 2023 18:50:22 +0000 (20:50 +0200)]
Add ReactorStmtCtx.getStorageNodeType()

The value here is shared by all subclasses except for
RootStatementContext, reduce code duplication.

Change-Id: I958b105afe109d3d55756d98f47b4845685dccb6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove SourceSpecificContext.getRoot() 61/105261/3
Robert Varga [Wed, 5 Apr 2023 17:19:59 +0000 (19:19 +0200)]
Remove SourceSpecificContext.getRoot()

The lifecycle here is a tad wild. Make sure the BuildContext has a
well-defined API to SourceSpecificContext and thus we prevent leakage of
SourceSpecificContext internals.

Change-Id: Ic0e4d1799dd0c3248fe50a6e3837d33fd04015bb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoHide SourceSpecificContext.getYangVersion() 60/105260/2
Robert Varga [Wed, 5 Apr 2023 17:31:15 +0000 (19:31 +0200)]
Hide SourceSpecificContext.getYangVersion()

This method is only used internally, hide it.

Change-Id: I8c1d1b2a9c55969c50c8c6f5286b8f43cdceb849
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoClean up NamespaceStorageSupport 59/105259/4
Robert Varga [Wed, 5 Apr 2023 15:54:35 +0000 (17:54 +0200)]
Clean up NamespaceStorageSupport

We have:
- needlessly public methods
- missing explicit final marker
- single-caller methods

Clean all that up.

Change-Id: If0a9bb8fb60a39fc4520cb110188596771272141
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoClean up NamespaceStmtCtx 58/105258/3
Robert Varga [Wed, 5 Apr 2023 15:47:56 +0000 (17:47 +0200)]
Clean up NamespaceStmtCtx

NamespaceStmtCtx.namespaceItem() has a useless generic capture for key
argument. Remove it and update javadocs and argument names.

Change-Id: Id6cf25c19d26252fdea512fb42a10cf66290e527
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove NamespaceStmtCtx.get(All)FromNamespace() 57/105257/3
Robert Varga [Wed, 5 Apr 2023 15:31:23 +0000 (17:31 +0200)]
Remove NamespaceStmtCtx.get(All)FromNamespace()

We have a slight overlap in method, address the two TODOs and remove the
methods.

Change-Id: Ief3143075c7518d59a6d6838e0ca7d77b5f7e087
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoAdd YangTextSchemaContextResolver feature support 37/105037/22
matus.matok [Mon, 27 Mar 2023 11:31:23 +0000 (13:31 +0200)]
Add YangTextSchemaContextResolver feature support

YangTextSchemaContextResolver does not provide a facility to control the
set of supported features. Add
YangTextSchemaContextResolver.registeredFeatures() and a specialized
Set<QName> implementation to provide backwards-compatible way of
specifying features.

The specialized implementation does not completely conform to
Set.equals()/Set.hashCode() specification and we therefore need to dance
a bit around it.

JIRA: YANGTOOLS-1463
Change-Id: I443d42a6859ce97f238117fabdb7bbdd42488ee5
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoUse a switch expression in SubstatementValidator 56/105256/1
Robert Varga [Wed, 5 Apr 2023 15:28:35 +0000 (17:28 +0200)]
Use a switch expression in SubstatementValidator

An expression implies exhaustiveness, which iis a tad more defensive.

Change-Id: I5d76093a1e45e152b1e57e5c320d8a77b539bbf9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove obsolete FIXME 55/105255/1
Robert Varga [Wed, 5 Apr 2023 15:12:04 +0000 (17:12 +0200)]
Remove obsolete FIXME

Namespace type captures were removed in commit 81b0bd062d5, hence this
FIXME is no longer relevant.

Change-Id: Iece723604116d7327084b492473aa95e4be4ebc9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoClean up YangTextSchemaContextResolver 48/105248/2
Robert Varga [Wed, 5 Apr 2023 00:12:06 +0000 (02:12 +0200)]
Clean up YangTextSchemaContextResolver

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

Change-Id: I955bdc8c133631cabeac138d0509b03cd679ad5b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoHide RootStatementContext 37/105237/2
Robert Varga [Tue, 4 Apr 2023 22:16:39 +0000 (00:16 +0200)]
Hide RootStatementContext

This class is not used anywhere and its capabilities are already
available via RootStmtContext. Hide it from the outside world, which
fixes a module-related warning.

Change-Id: Ia234accce1814004224a7fb58ad3886fbe1ff4ef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoImprove findFirstDeclaredSubstatement() 36/105236/1
Robert Varga [Tue, 4 Apr 2023 22:04:25 +0000 (00:04 +0200)]
Improve findFirstDeclaredSubstatement()

Remove a raw Class cast, which in turn removes the need to do unchecked
casts.

Change-Id: I4f3a58e78dc6c87866d7878383169f9efefbde94
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoImprove mutatesCtxImpl() 35/105235/1
Robert Varga [Tue, 4 Apr 2023 21:54:25 +0000 (23:54 +0200)]
Improve mutatesCtxImpl()

Remove raw type cast, which removes the need for suppressions.

Change-Id: Ibab30378d693b28bbf85e3ba92607e71aa3eba84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoImprove EffectiveInstances.attachCopy() 34/105234/1
Robert Varga [Tue, 4 Apr 2023 21:44:52 +0000 (23:44 +0200)]
Improve EffectiveInstances.attachCopy()

Use local variable type inference to reduce code clutter.

Change-Id: I52d3450d87aefbd1ae3bb806fbfd37aee52c979f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove an explicit cast from unmaskUndeclared() 33/105233/1
Robert Varga [Tue, 4 Apr 2023 21:41:43 +0000 (23:41 +0200)]
Remove an explicit cast from unmaskUndeclared()

Use an instanceof pattern to have the return readily-cast.

Change-Id: I253fc8848f828e76fb421a86430b490646bc1d9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoImprove StatementContextBase.wrapWithOriginal() 32/105232/1
Robert Varga [Tue, 4 Apr 2023 21:28:17 +0000 (23:28 +0200)]
Improve StatementContextBase.wrapWithOriginal()

We can use local variable type inference to reduce warnings and also
instanceof pattern to remove an explicit cast.

Change-Id: I80572a5392b9a94ed46fa6fdf28cb4a21580995c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoModernize IfFeatureExpr 30/105230/2
Robert Varga [Tue, 4 Apr 2023 17:53:17 +0000 (19:53 +0200)]
Modernize IfFeatureExpr

Use local variable type inference to ditch some of the verbosity. Also
use a switch expression and add a few comments.

Change-Id: I2d1dd40028b00c756cd7e85a6b3086b6f0c63ed4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoImprove StmtContextUtils.checkFeatureSupport() 29/105229/1
Robert Varga [Tue, 4 Apr 2023 17:40:47 +0000 (19:40 +0200)]
Improve StmtContextUtils.checkFeatureSupport()

FeatureStatement is defined to have a IfFeatureExpr, bind directly to
it. This removes the dependency on Predicate, removes the need to
suppress warnings and allows the JVM to more aggressively optimize.

Change-Id: I2e9a0ed68298dd5e08738bba42a4fff0c97505a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoModernize StmtContextUtils 28/105228/1
Robert Varga [Tue, 4 Apr 2023 17:39:58 +0000 (19:39 +0200)]
Modernize StmtContextUtils

Use local variable type inference to simplify code.

Change-Id: If693e1474ee9ac675400d1092840dfc8e0238e17
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoMigrate yang-model-ri to JUnit 5 96/105096/3
Robert Varga [Wed, 29 Mar 2023 08:40:58 +0000 (10:40 +0200)]
Migrate yang-model-ri to JUnit 5

This is a straightforward migration.

Change-Id: I7957e83e2bd47da07194dc207aa2fd221d8acedc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoMigrate yang-model-spi to JUnit5 95/105095/2
Robert Varga [Wed, 29 Mar 2023 08:34:28 +0000 (10:34 +0200)]
Migrate yang-model-spi to JUnit5

This is mostly a rewrite-driven migration.

Change-Id: Icb01d01d7cd3daa37fbdfff8b5cd932eb75e4c58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoSimplify YangParserConfiguration.equals() 70/105070/1
Robert Varga [Mon, 27 Mar 2023 19:59:01 +0000 (21:59 +0200)]
Simplify YangParserConfiguration.equals()

Use an instanceof pattern to use a simple expression.

Change-Id: Idacf5673ccde383027edcc105da72fbafce9f2f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoMigrate yang-model-util to JUnit5 54/104654/6
Robert Varga [Wed, 1 Mar 2023 11:43:31 +0000 (12:43 +0100)]
Migrate yang-model-util to JUnit5

This is an automated conversion, with migration away from Hamcrest where
useful.

Change-Id: I762d9e7b124e0b07511b847ee594e9386cae1f4d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove 'throws IOException' declaration 09/105009/1
Robert Varga [Fri, 24 Mar 2023 12:27:46 +0000 (13:27 +0100)]
Remove 'throws IOException' declaration

This is a code smell reported by Sonar, fix it.

Change-Id: I0a4f2155f0fbf8f69ccd7bc4a1f25202b1fc4bbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoMigrate yang-model-api to JUnit5 86/104886/2
Robert Varga [Wed, 15 Mar 2023 13:10:00 +0000 (14:10 +0100)]
Migrate yang-model-api to JUnit5

This is a rather trivial migration.

Change-Id: I37f6d307a83967028c75dbfb4d57b86000f0a9f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoOptimize StmtContextUtils.isMandatoryNode() 89/104889/1
Robert Varga [Wed, 15 Mar 2023 17:50:22 +0000 (18:50 +0100)]
Optimize StmtContextUtils.isMandatoryNode()

Use instanceof pattern and a switch expression to remove an explicit
cast and make the implementation less verbose.

Change-Id: Ic4800aac65469565f4aead71a740f96aa3d126bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRemove StmtContextUtils.getRootModuleQName() 88/104888/2
Robert Varga [Wed, 15 Mar 2023 17:27:35 +0000 (18:27 +0100)]
Remove StmtContextUtils.getRootModuleQName()

This method has been deprecated in previous release, remove it.

Change-Id: Id4e89f488c02cab92cefa224ebd4131b848524dc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoAdd an StmtContextUtils.getModuleQName() overload 87/104887/2
Robert Varga [Wed, 15 Mar 2023 17:25:42 +0000 (18:25 +0100)]
Add an StmtContextUtils.getModuleQName() overload

We have getRootModuleQName(), which unfortunately ends up polluting
returns with nulls. Add a getModuleQName(), which does not tolerate
null argument and therefore results in a non-null return.

Migrate users and depreate getRootModuleQName() for removal.

Change-Id: Ie28ef812cab87917fbe2b6eb07142c39b857fff1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoCheck requested schema tree statement namespace 97/104197/11
Sangwook Ha [Fri, 27 Jan 2023 22:24:14 +0000 (14:24 -0800)]
Check requested schema tree statement namespace

When we have a reactor when two children of an InferredStatementContext
differ only in namespace, we cannot blindly service
requestSchemaTreeChild().

Check whether the namespaces match, as we can only materialize
statements that match our targetModule.

JIRA: YANGTOOLS-1480
Change-Id: I4d9c6e6361fe2d5383e6de43e3c1bb54bac4e935
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoFix bits/instance-identifier value serdes 45/103945/18
Robert Varga [Fri, 6 Jan 2023 15:30:27 +0000 (16:30 +0100)]
Fix bits/instance-identifier value serdes

Bits and instance-identifier values need to be recognized. Fix their
serialization and parsing and enable tests.

JIRA: YANGTOOLS-1473
Change-Id: If5b40d4642e4d8353e8dfad492166987fc3c536b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
14 months agoFix identity-ref value parsing/serialization 44/103944/18
Robert Varga [Fri, 6 Jan 2023 15:30:27 +0000 (16:30 +0100)]
Fix identity-ref value parsing/serialization

When encountering a QName value in a leaf, a leaf-list or implied as the
value of a key, we need to properly encode it. The same is true when
parsing, where we have to consult current namespace mapping.

As a side-effect of this, we are also fixing the case of a leaf-list
entry referenced in a path argument -- which is important for all
non-String types.

JIRA: YANGTOOLS-1473
Change-Id: Id50ebd9a3c0c1378f1af8451b86c66e323757eba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
14 months agoFix String value parsing/serialization 41/103941/24
Robert Varga [Fri, 6 Jan 2023 15:30:27 +0000 (16:30 +0100)]
Fix String value parsing/serialization

When encoding user-supplied values from user we need to be mindful of
their actual content: we cannot just use single quotes (') everywhere,
as the value itself can contain a single quote, in which case the
resulting string would have unbalanced quotes and nominally unparseable.

Adjust both sides of the serialization picture to account for this and
use YANG section 6.1.3 for escaping rules.

JIRA: YANGTOOLS-1473
Change-Id: I0df9beaf720a78682b6bde606a1359e7f1a09df8
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoUpdate test suite 73/104873/11
Robert Varga [Tue, 14 Mar 2023 07:49:38 +0000 (08:49 +0100)]
Update test suite

Change I6226cc8ebe48acc03a62309efec2ab205549e0fb has a few deficiencies
in the models and test consistency. Improve the tests before we start
addressing the issues.

JIRA: YANGTOOLS-1473
Change-Id: Ie1f4e5fa99a8258abe09c005d352dd971a98c051
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoImprove AbstractImmutableNormalizedNodeBuilder 66/104866/3
Robert Varga [Mon, 13 Mar 2023 22:48:19 +0000 (23:48 +0100)]
Improve AbstractImmutableNormalizedNodeBuilder

We are accessing fields twice, which elicits an Eclipse warning about
nullability. While this cannot really happen, as the fields cannot
become null once they have been non-null, we can improve the code by
essentially providing our alternative to checkState().

Change-Id: I9263cba1a2e9b46377556de423227ee02c003982
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoImprove ImmutableAnydataNodeBuilder null safety 65/104865/2
Robert Varga [Mon, 13 Mar 2023 22:47:39 +0000 (23:47 +0100)]
Improve ImmutableAnydataNodeBuilder null safety

Use a @NonNull annotation to fix an Eclipse warning.

Change-Id: Ibe8f8cf18c3ea7a402fac8e27c2a30b28604c6dc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoImprove OperationDefinition guarantees 82/104882/1
Robert Varga [Tue, 14 Mar 2023 20:11:39 +0000 (21:11 +0100)]
Improve OperationDefinition guarantees

We guarantee non-nullness across the board, use @NonNullByDefault
to express that.

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