yangtools.git
19 months agoImprove StatementContextBase.stream{Declared,Effective} 51/102651/1
Robert Varga [Tue, 4 Oct 2022 13:08:07 +0000 (15:08 +0200)]
Improve StatementContextBase.stream{Declared,Effective}

We have an implementation invariant of returning ReactorStmtCtx,
make sure we expose it, removing the need for unchecked casts.

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

19 months agoFix yang-data extension definition 50/102650/1
Peter Suna [Thu, 26 May 2022 09:58:49 +0000 (11:58 +0200)]
Fix yang-data extension definition

The definition on ietf-restconf's yang-data is being rather exploited in
the wild, with a license to contain choices and anydata. These are
essentially allowed by other tooling, hence we need to also relax our
requirements.

This implies we cannot really expose the container directly, but rather
have to implement DataNodeContainer instead -- with the implied API
breakage. This is fine due to @Beta-level contract of all interfaces
involved.

Since we are breaking semantics here, also ditch the notion that the
yang-data argument can be parsed into a QName and instead reuse the
schema tree child's QName as the value required by SchemaNode contract.

JIRA: YANGTOOLS-1443
Change-Id: I3f78f71ea2980bf84f409d1ec89979e9e7b200ae
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6dec3b24ef9055b777e7ea09b2006a1f867da827)

19 months agoFix DataTreeCandidateNodes handling of deleted nodes 40/102540/1
Robert Varga [Mon, 3 Oct 2022 08:42:11 +0000 (10:42 +0200)]
Fix DataTreeCandidateNodes handling of deleted nodes

Recursive candidate should be used only for DistinctNodeContainer,
not all NormalizedNodeContainers. Fix the check so that we do not hit a
ClassCastException.

JIRA: YANGTOOLS-1455
Change-Id: I6a89f8e59a7f8d8b36c5c5d2990290f66f79f529
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a3bdb0fbc05db361f7c105469ffd73b1e35390be)

21 months agoBump versions to 9.0.2-SNAPSHOT 35/102135/1
Robert Varga [Wed, 17 Aug 2022 14:21:06 +0000 (16:21 +0200)]
Bump versions to 9.0.2-SNAPSHOT

This starts the next development iteration.

Change-Id: If3a6260f46cfdc51b29035ea62d8a3780c05bf15
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoDo not use substatements in StmtContextUtils.getRootModuleQName() 33/102133/1
Sangwook Ha [Tue, 7 Jun 2022 21:12:36 +0000 (14:12 -0700)]
Do not use substatements in StmtContextUtils.getRootModuleQName()

Building effective model fails when a grouping in a submodule
is augmented from another submodule or the unique statement points
to a leaf in a grouping from another submodule.

Add test cases to reproduce the issues, which points to us accessing
substatements of submodules after all references have been resolved.

Since we already rely on SOURCE_LINKAGE being complete in this method
(e.g. ModuleCtxToModuleQName being populated), switch from using
statement enumeration to also using the BelongsToPrefixToModuleCtx
namespace, which resolved during that same phase.

JIRA: YANGTOOLS-1436
Change-Id: I71eb1122bf7c3820043a3197249a3b2fba6e9e8c
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 30f4e375338124bbb66d2bf1e1c65d0968fd1f0e)

21 months agoUse SSv1 during writeout 26/102126/1
Robert Varga [Wed, 17 Aug 2022 07:45:08 +0000 (09:45 +0200)]
Use SSv1 during writeout

Make sure we are not dependent on SingletonSet hierarchy in
serialization writeout path.

Change-Id: I7b602f166bccc418ea27af0b887f5868fadbf9e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0fc692ac97b7a899750bc4eb6559dacdabdc0433)

21 months agoAdd SSv1 25/102125/1
Robert Varga [Wed, 17 Aug 2022 07:42:35 +0000 (09:42 +0200)]
Add SSv1

Add a serialization proxy for SingletonSet, so that we have explicit
control over the format.

Change-Id: Iedf53fe200215fbe1236464677e42b7d27d0caf5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3e086972fad7b1d81b8a9d3e4ed0f84f2e8822fe)

21 months agoUse instanceof pattern in SingletonSet 15/102115/1
Robert Varga [Wed, 17 Aug 2022 06:45:54 +0000 (08:45 +0200)]
Use instanceof pattern in SingletonSet

We can simplify our equals() implementation a bit, let's do that.

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

21 months agoUse serialization proxy for ImmutableOffsetMap 14/102114/1
Robert Varga [Wed, 10 Aug 2022 22:15:54 +0000 (00:15 +0200)]
Use serialization proxy for ImmutableOffsetMap

This patch switches to using an Externalizable proxy, allowing us to
properly inject fields.

Change-Id: I2a556713f2ab47a3ea1fabff7a5e45da02494c81
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4481fd2b8436bd0d040b804750fab6692d3dd5b4)

21 months agoFixup IOMv1 13/102113/1
Robert Varga [Tue, 16 Aug 2022 21:50:36 +0000 (23:50 +0200)]
Fixup IOMv1

We are missing serialVersionUID, fix that up.

Change-Id: I21b8f7146a52f8c6c004df30acf386086a452d8d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8165d1ca88da1ba03aa13e25aa69326fad7cf1d8)

21 months agoAdd IOMv1 proxy 12/102112/1
Robert Varga [Wed, 10 Aug 2022 22:14:27 +0000 (00:14 +0200)]
Add IOMv1 proxy

ImmutableOffsetMap is using ugly reflection, which we are ditching. Add
the serialization proxy for compatibility.

Change-Id: I8687eee174462f62cdba927eb7c6d7386f7009ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1c1146b3a6a4dffa1d5b2e679ab82755456d123e)

21 months agoRemove unneeded @NonNull 11/102111/1
Robert Varga [Tue, 16 Aug 2022 19:53:05 +0000 (21:53 +0200)]
Remove unneeded @NonNull

The contract is specified by super, no need for these.

Change-Id: I93638a90eace123c1a4c7ea33d93a1f2d1de067a
(cherry picked from commit c2e69576827d6aaf4c9d0b599fa3a8efd35d0c45)

21 months agoUse instanceof patterns in MutableOffsetMap 10/102110/1
Robert Varga [Wed, 10 Aug 2022 22:42:19 +0000 (00:42 +0200)]
Use instanceof patterns in MutableOffsetMap

We can simplify the code a bit through patterns.

Change-Id: I9fecdeebfa308485bbb57081ced484d4426aa6ab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8bb4a3e29171d7cf5a94d41f0909e7a8d896be4a)

21 months agoSeal util classes 09/102109/1
Robert Varga [Wed, 10 Aug 2022 20:21:28 +0000 (22:21 +0200)]
Seal util classes

Most of our utility classes can be safely sealed, make sure we do that.

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

21 months agoUse @Serial in util 08/102108/1
Robert Varga [Wed, 10 Aug 2022 19:59:37 +0000 (21:59 +0200)]
Use @Serial in util

This improves code safety quite a bit and allows us to perform a
long-needed audit.

Change-Id: I04161cfe8e6a367e1ae0d53a2628fbf72035ecde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 14fb0b4eba9e86b7a6358f9c29527c9b9d1ec5f1)

21 months agoUse instanceof patterns 07/102107/1
Robert Varga [Wed, 10 Aug 2022 20:04:26 +0000 (22:04 +0200)]
Use instanceof patterns

We can simplify the code a bit by using pattern matching.

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

21 months agoUse instanceof pattern 06/102106/1
Robert Varga [Wed, 10 Aug 2022 13:20:23 +0000 (15:20 +0200)]
Use instanceof pattern

We can simplify things a bit by removing unneeded casts.

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

21 months agoDo not iterate over SchemaPath 05/102105/1
Robert Varga [Wed, 10 Aug 2022 12:33:17 +0000 (14:33 +0200)]
Do not iterate over SchemaPath

We are exposing a List here, so we can things a tad more efficiently.

Change-Id: I310b626f5b8e7b94ca0cfade03833a0774931dab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0801c308b60fd9a86061da2fc43db21dfdb90768)

21 months agoUse instanceof patterns 04/102104/1
Robert Varga [Wed, 10 Aug 2022 11:10:28 +0000 (13:10 +0200)]
Use instanceof patterns

Modernize this a bit to remove unneeded casts.

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

21 months agoRemove use of DeviateKind.getKeyword() 25/102025/1
Robert Varga [Tue, 9 Aug 2022 19:46:30 +0000 (21:46 +0200)]
Remove use of DeviateKind.getKeyword()

Update javadoc and use argument() instead.

Change-Id: Id5af2a39bb253d610fc30ebe5264d3537e04886c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoUse concrete implementation for base decimal constraints 24/102024/1
Robert Varga [Tue, 9 Aug 2022 17:39:21 +0000 (19:39 +0200)]
Use concrete implementation for base decimal constraints

There are package-internal constants, make sure we advertize the fact
they are resolved.

Change-Id: Iaf5d8419385955531b8f627ec8a9f7d3432ab7ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoSeal SchemaNodeIdentifier 20/102020/3
Robert Varga [Tue, 9 Aug 2022 16:49:39 +0000 (18:49 +0200)]
Seal SchemaNodeIdentifier

We do not allow SchemaNodeIdentifier to be subclassed outside of its
package, make sure the compiler understands that as well.

Change-Id: Ia61cebfa30bc77b8055d3b7c4e01fef73b7b067f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoSeal ValueRange 19/102019/1
Robert Varga [Tue, 9 Aug 2022 16:30:38 +0000 (18:30 +0200)]
Seal ValueRange

We really want to make sure we only use the two provided instantiations,
make sure to seal the base class.

Change-Id: I8bd1530fbe5874f37e3998fd528ee0cd48d54373
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoGuarantee @NonNull return from ValueRange 18/102018/1
Robert Varga [Tue, 9 Aug 2022 16:30:04 +0000 (18:30 +0200)]
Guarantee @NonNull return from ValueRange

We always return a non-null, make sure we express that.

Change-Id: I737065b6f87e6891f4b43d500443a5bb12cffdfc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoUse instanceof pattern match in ValueRange 17/102017/1
Robert Varga [Tue, 9 Aug 2022 16:28:59 +0000 (18:28 +0200)]
Use instanceof pattern match in ValueRange

This simplifies the equality contract a bit.

Change-Id: Ie59c58e70e8c7de2b1898f58c99c84694073f86a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoAdd support for RFC8819 "module-tag" extension 42/100542/31
ivan.martiniak [Fri, 6 May 2022 10:30:39 +0000 (12:30 +0200)]
Add support for RFC8819 "module-tag" extension

Schema context successfully recognizes ModuleTagEffectiveStatementImpl
object, raw representation in the yang file: tags:module-tag "ietf:tag";
Module-tag extension is fully supported.

JIRA: YANGTOOLS-1315
Change-Id: I5ce2ce7ae57febf80c71de68bc37422e5a5431f7
Signed-off-by: Ivan Martiniak <ivan.martiniak@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoDeprecate XMLStreamNormalizedNodeStreamWriter.create() 04/102004/3
Robert Varga [Mon, 8 Aug 2022 08:43:49 +0000 (10:43 +0200)]
Deprecate XMLStreamNormalizedNodeStreamWriter.create()

SchemaPath is going away, let's make sure users are guided towards
alternative methods.

JIRA: YANGTOOLS-1451
Change-Id: Id49381cfd0d0b46f623b223c4f23127c14d26134
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoMark deprecated methods for removal 03/102003/2
Robert Varga [Mon, 8 Aug 2022 08:38:13 +0000 (10:38 +0200)]
Mark deprecated methods for removal

We have a number of methods deprecated, but not marked for removal.
Update them along with the release where they were deprecated.

Change-Id: I20d56689d1c0349dc8f41b823d293576f40b5bb7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove a SchemaPath reference 06/102006/1
Robert Varga [Mon, 8 Aug 2022 08:54:29 +0000 (10:54 +0200)]
Remove a SchemaPath reference

We have a replacement construct, which accurately captures statement
hierarchy. Use that in javadocs instead of SchemaPath.

Change-Id: I1a5e02a5515a000826c458adee378a451c39f9c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoConvert yang-data-codec-gson to JPMS 00/102000/8
Robert Varga [Sun, 7 Aug 2022 19:33:14 +0000 (21:33 +0200)]
Convert yang-data-codec-gson to JPMS

This is an automatic module, jump the ship and become a full module.

JIRA: YANGTOOLS-1449
Change-Id: Ib1847be1e684e3a694f110d8a3d6b0166d52259c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoClean up JSONNormalizedNodeStreamWriter 02/102002/1
Robert Varga [Sun, 7 Aug 2022 19:31:05 +0000 (21:31 +0200)]
Clean up JSONNormalizedNodeStreamWriter

This was missed in review, fix it up.

Change-Id: Ibad2e8f1a9e156bacce83eba3cde7cfd690e65bd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoDeprecate JSONNormalizedNodeStreamWriter.create*Writer() 99/101999/7
Robert Varga [Sun, 7 Aug 2022 19:31:05 +0000 (21:31 +0200)]
Deprecate JSONNormalizedNodeStreamWriter.create*Writer()

Deprecate methods that use SchemaPath for identification. Introduce
replacatement methods where appropriate.

JIRA: YANGTOOLS-1450
Change-Id: I7418873de01094aed75670cbfea18d221224814d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoIntegrate JSONCodecFactory specializations 96/101996/7
Robert Varga [Sun, 7 Aug 2022 18:33:31 +0000 (20:33 +0200)]
Integrate JSONCodecFactory specializations

There is no point in keeping simple subclasses separate, move them
to be nest-mates and tighen them up. This also integrates
JSONInstanceIdentifierCodec, as it provides some brevity.

Change-Id: Iaea1cb529603976324516516a7f172b33f68e127
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoSeal JSONCodecFactory 95/101995/6
Robert Varga [Sun, 7 Aug 2022 18:28:10 +0000 (20:28 +0200)]
Seal JSONCodecFactory

The factory can only be instantiated from within the package due to
package-private constructor. It is therefore safe to seal.

Change-Id: Ia03e553b6ee9a3080aad6112278cea45cab99da7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoCleanup Bug5446Test 98/101998/2
Robert Varga [Sun, 7 Aug 2022 19:18:33 +0000 (21:18 +0200)]
Cleanup Bug5446Test

Change-Id: I2ec91057ccdd9b84bf04c8abcf48ed30119719d7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoFix a null warning 97/101997/2
Robert Varga [Sun, 7 Aug 2022 18:59:02 +0000 (20:59 +0200)]
Fix a null warning

Bug4501Test should require the node to be present before accessing
its body.

Change-Id: Iec99007f73aae3735a1baba94f1944abaed20c34
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoBump odlparent to 11.0.1 96/101796/3
Robert Varga [Mon, 11 Jul 2022 11:05:34 +0000 (13:05 +0200)]
Bump odlparent to 11.0.1

Pick up latest upgrades from upstream.

Change-Id: Ib23e45796564d846e7b72c9648f3fc9f185be0c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoAdd test for statement prerequisites and materialization 26/101926/2
Peter Suna [Fri, 29 Jul 2022 14:21:19 +0000 (16:21 +0200)]
Add test for statement prerequisites and materialization

Add test to Building SchemaContext when augmenting submodel container
with unique leafs inside list.

JIRA: YANGTOOLS-1434
Change-Id: I8e1984bc00ca94f72a264d20925ab55721cb0ccc
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoImprove Decimal64.toString() implementation 35/101635/22
OleksandrZharov [Tue, 28 Jun 2022 14:56:08 +0000 (16:56 +0200)]
Improve Decimal64.toString() implementation

Change implementation of Decimal64.toString() method to:
pad unscaled value to scale + 1 size string, insert '.',
and remove trailing zeros.

JIRA: YANGTOOLS-1439
Change-Id: Ifb21ce4cdcf17d91da669c8f2c5e73de6a3edf22
Signed-off-by: OleksandrZharov <Oleksandr.Zharov@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
22 months agoBump versions to 9.0.1-SNAPSHOT 11/101611/1
Robert Varga [Mon, 20 Jun 2022 12:20:38 +0000 (14:20 +0200)]
Bump versions to 9.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: I293b34b52d8bf923dcb4af234b55207d0d8b4bf1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
22 months agoCrossSourceStatementReactor.BuildAction should be final 10/101610/2
Robert Varga [Mon, 20 Jun 2022 12:11:59 +0000 (14:11 +0200)]
CrossSourceStatementReactor.BuildAction should be final

We do not want this class to be subclassed, make sure it is final.

Change-Id: I3f0e39b13a4f5b09fc454e27acd41a5229cf7a1d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
22 months agoAdd YangLibModule et al. 99/100999/16
Robert Varga [Thu, 5 May 2022 00:21:56 +0000 (02:21 +0200)]
Add YangLibModule et al.

Introduce ietf-yang-library equivalents and a resolver that trusts
them by default. This routes the information we need to the reactor.

JIRA: YANGTOOLS-837
Change-Id: Iab12347ea065f7d6351b0943ff3416fdb23eb0e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
22 months agoUse AssertionError 09/101609/1
Robert Varga [Mon, 20 Jun 2022 11:39:07 +0000 (13:39 +0200)]
Use AssertionError

We have an accidental use of opentest4j, make sure we use plain
AssertionError.

Change-Id: I06e0b184fdc9d129d70ba927e8f6d0d9f4001ceb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUpdate yang-maven-plugin requirements 73/101573/2
Robert Varga [Mon, 13 Jun 2022 10:56:31 +0000 (12:56 +0200)]
Update yang-maven-plugin requirements

We require maven-3.8, make sure we update our dependencies.

Change-Id: I0b20df4f138377b1ff2ef9382a0e366c8fbbfa79
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoMove (Abstract)IllegalArgumentCodec to yang.data.api.codec 61/100561/2
Robert Varga [Tue, 12 Apr 2022 11:18:46 +0000 (13:18 +0200)]
Move (Abstract)IllegalArgumentCodec to yang.data.api.codec

The only users of this construct live in yang-data-{api,util,impl}. Move
the contract there and un-deprecate it.

JIRA: YANGTOOLS-1332
Change-Id: Ie19b09e108a4bac8946c080da563fdb9ccdaae6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse assertInstanceOf 42/101542/1
Robert Varga [Thu, 9 Jun 2022 10:04:13 +0000 (12:04 +0200)]
Use assertInstanceOf

No need to use Hamcrest, as we have a JUnit5 version of this assertion.

Change-Id: Ibe915ea3d74bff941237d33ad33d002180958590
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoMigrate yang-data-api to JUnit5 66/101466/1
Robert Varga [Mon, 6 Jun 2022 11:36:46 +0000 (13:36 +0200)]
Migrate yang-data-api to JUnit5

We have a few tests here, migrate them over.

Change-Id: I56dd6bbeda75a9225644aacb242ecc46a88878f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoFreeze odlparent at 11.0.0 65/101465/1
Robert Varga [Mon, 6 Jun 2022 11:07:46 +0000 (13:07 +0200)]
Freeze odlparent at 11.0.0

There is a release out there, use that instead of snapshots.

Change-Id: I411b2a7b0e850be56382be2f881211a5a74d18d6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoMigrate yang-common-netty to JUnit5 70/101370/2
Robert Varga [Mon, 30 May 2022 16:57:56 +0000 (18:57 +0200)]
Migrate yang-common-netty to JUnit5

We have only two tests, migrate them over.

Change-Id: I3a4bd9153cdae01e685b6cea02340611d500cb7a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoMigrate yang-xpath-impl to JUnit5 69/101369/2
Robert Varga [Mon, 30 May 2022 16:52:49 +0000 (18:52 +0200)]
Migrate yang-xpath-impl to JUnit5

We have only a single test, migrate it.

Change-Id: I046473eb56ff3f6869c96d169aab74bd605bbe9b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoMigrate yang-repo-fs to JUnit5 66/101366/1
Robert Varga [Mon, 30 May 2022 16:38:09 +0000 (18:38 +0200)]
Migrate yang-repo-fs to JUnit5

These are simple tests, migrate them.

Change-Id: Ied27283b229ae27f8d5bef6b8af0554b5ade1bc9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoRemove YangTextSnippetIterator.Quoting 31/101331/10
Robert Varga [Sun, 29 May 2022 18:52:07 +0000 (20:52 +0200)]
Remove YangTextSnippetIterator.Quoting

Eliminate internal enum and inline the dispatch, eliminating the need
for a default case.

Change-Id: I1b728b5b1652bde5f044a9a4e57b30d53f27bfc2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoModernize yang-parser-reactor 41/101341/4
Robert Varga [Sun, 29 May 2022 20:41:52 +0000 (22:41 +0200)]
Modernize yang-parser-reactor

Use switch expressions and pattern match on instanceof to improve code
density.

Change-Id: Ia49f28782258986393e8932403a8468210b84856
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse arrow cases in YT1193Test 40/101340/4
Robert Varga [Sun, 29 May 2022 20:40:33 +0000 (22:40 +0200)]
Use arrow cases in YT1193Test

Drop a few lines with a more expressive construct.

Change-Id: I3c68804d0ac8655c195c1c6b2fe95e057593b744
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expression in yang-parser-impl 39/101339/4
Robert Varga [Sun, 29 May 2022 20:39:38 +0000 (22:39 +0200)]
Use switch expression in yang-parser-impl

A switch is more expressive, use it for initialization of reference
factory.

Change-Id: Ic2b9d2dd890c02f2189c632c8e1909cf62326c0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expression in rfc6241 support 38/101338/4
Robert Varga [Sun, 29 May 2022 20:38:18 +0000 (22:38 +0200)]
Use switch expression in rfc6241 support

An expression is more dense.

Change-Id: I44f814369d9d0ce50de65117c109cfbbc65acda9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expressions 37/101337/4
Robert Varga [Sun, 29 May 2022 20:00:45 +0000 (22:00 +0200)]
Use switch expressions

AbstractModifiedNodeBasedCandidateNode can prune default cases if we use
switch expressions.

Change-Id: I2a8dc3ce0b5cf875a5f09e3f0b242b712d806b7f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse arrow case in ValueNodeModificationStrategy 36/101336/3
Robert Varga [Sun, 29 May 2022 19:54:06 +0000 (21:54 +0200)]
Use arrow case in ValueNodeModificationStrategy

Reduce verbosity by using non-fall-through arrow cases, improving
code density.

Change-Id: I0d5674a27f8c449b814ea37c0a5d94cae23336f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoModernize SchemaAwareApplyOperation 35/101335/3
Robert Varga [Sun, 29 May 2022 19:51:06 +0000 (21:51 +0200)]
Modernize SchemaAwareApplyOperation

Use instanceof pattern matching and modernize switch statement use,
by use of arrow cases and switch expressions.

Change-Id: Ieed9342918a627bb80968d4fd3ecab27203f6a1c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoModernize switch use in ModifiedNode 34/101334/3
Robert Varga [Sun, 29 May 2022 19:45:34 +0000 (21:45 +0200)]
Modernize switch use in ModifiedNode

Use arrow cases and switch expressions to improve clarity.

Change-Id: Id34be473139ee20b2dd30da23063ac20d2a29787
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoModernize yang-repo-{api,spi} 33/101333/2
Robert Varga [Sun, 29 May 2022 19:37:25 +0000 (21:37 +0200)]
Modernize yang-repo-{api,spi}

Use pattern matching on instanceof to simplify our code.

Change-Id: I1399f78a5b25558b6437434e1c316790cfc50e23
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse modern switch in yang-model-export 20/101320/5
Robert Varga [Sun, 29 May 2022 17:34:10 +0000 (19:34 +0200)]
Use modern switch in yang-model-export

We can use arrow cases and switch expressions to improve clarity.

Change-Id: Id8897dfa09bf2608b90c730cfdf260d84f34c5c0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expressions in yang-data-util 30/101330/5
Robert Varga [Sun, 29 May 2022 18:32:09 +0000 (20:32 +0200)]
Use switch expressions in yang-data-util

We have two dispatches, update them to switch expressions.

Change-Id: Iebeaf863e47ffd2a8fad260ca429187a42bd4138
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse a switch expression in DataTreeConfiguration 29/101329/5
Robert Varga [Sun, 29 May 2022 18:27:39 +0000 (20:27 +0200)]
Use a switch expression in DataTreeConfiguration

We have a switch on an enum, use an expression to cut an unneeded
branch.

Change-Id: I9eedf58dcca62e1005c07b0f53d398ceaa4481e9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expressions in yang-data-impl 28/101328/5
Robert Varga [Sun, 29 May 2022 18:25:13 +0000 (20:25 +0200)]
Use switch expressions in yang-data-impl

Switch expressions give us exhaustivity and more compact code, use them
where appropriate.

Change-Id: I13a9f146d92b17c1b87725926b4da6a0844cb97a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoSeal BinaryStringCodec 27/101327/5
Robert Varga [Sun, 29 May 2022 18:23:52 +0000 (20:23 +0200)]
Seal BinaryStringCodec

We have only internal subclasses, seal the public class to prevent
misuse.

Change-Id: Id1b9a1cdac067d626af42c91e22b90fe40bf290e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expression in NIPv2 26/101326/5
Robert Varga [Sun, 29 May 2022 18:23:09 +0000 (20:23 +0200)]
Use switch expression in NIPv2

Improve clarity a bit.

Change-Id: I390d419a9afefd4bf79ea519ef441270190c69e1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoModernize GSON codec a bit 25/101325/4
Robert Varga [Sun, 29 May 2022 18:02:42 +0000 (20:02 +0200)]
Modernize GSON codec a bit

Use instanceof pattern matching and switch expressions.

Change-Id: I48362f161187de4b76314b889e59994dfbf1d107
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoFix checkArgument() format string 24/101324/4
Robert Varga [Sun, 29 May 2022 18:09:11 +0000 (20:09 +0200)]
Fix checkArgument() format string

We should be using %s, not {} please holder.

Change-Id: I80e22247cef602f50856e792baa8be83b815ebf7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoModernize SchemaInferenceStack 23/101323/4
Robert Varga [Sun, 29 May 2022 17:52:22 +0000 (19:52 +0200)]
Modernize SchemaInferenceStack

Use arrow cases and instanceof pattern matches to reduce verbosity.

Change-Id: I554937e564c76b978d0b53e89476a18628b15e79
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expressions in EffectiveStatementMixins 22/101322/4
Robert Varga [Sun, 29 May 2022 17:37:24 +0000 (19:37 +0200)]
Use switch expressions in EffectiveStatementMixins

We can improve clarity with expressions, use them.

Change-Id: I9ec47d88baeb9df5d13b2d8285c6b4adc826162d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expressions in yang-model-ri 21/101321/2
Robert Varga [Sun, 29 May 2022 17:36:01 +0000 (19:36 +0200)]
Use switch expressions in yang-model-ri

We are dealing with enumerations, hence we can take advantage of
exhaustiveness of switch expressions.

Change-Id: I370e3bf9004a540eaf1e55eb1d7f82862451a322
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expressions in util 19/101319/1
Robert Varga [Sun, 29 May 2022 17:32:38 +0000 (19:32 +0200)]
Use switch expressions in util

We have three places where switch expressions are appropriate, use them
to improve clarity.

Change-Id: Ia46a06608202bcc460c4de57eb1d4afccb5a92a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoModernize yang-data-codec-binfmt 12/101312/5
Robert Varga [Thu, 26 May 2022 21:06:16 +0000 (23:06 +0200)]
Modernize yang-data-codec-binfmt

Use JDK17 features to make the code a bit more less verbose and more
resilient.

Change-Id: I8219ca1a6507940b6d2e24800ff29c1d350469e2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse on-demand component activation 94/101294/1
Robert Varga [Wed, 25 May 2022 14:53:23 +0000 (16:53 +0200)]
Use on-demand component activation

SCR provides for a way to activate components on-demand, so they end up
being dormant when not used. Take advantage of this and also lower the
amount of logging we perform during activation/deactivation.

Change-Id: I3bbdc6bf1d6e20b7e9440f3e3c62b075aa826bbc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoNormalize Decimal64 to fraction-digits 70/101270/11
Robert Varga [Mon, 23 May 2022 18:19:57 +0000 (20:19 +0200)]
Normalize Decimal64 to fraction-digits

When parsing a Decimal64, we need to scale it to fraction-digits
to ensure the input matches the expected range.

JIRA: YANGTOOLS-1437
Change-Id: I535eab4a20d30a742e94c3a6342e113cb569d0bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoAdd Decimal64.scaleTo() 79/101279/6
Robert Varga [Wed, 25 May 2022 08:27:47 +0000 (10:27 +0200)]
Add Decimal64.scaleTo()

Decimal64.valueOf(String) results in variable-scale results, based on
the input string. This is sub-optimal when we want to compare values
of particular type -- those should be governed by fraction-digits and
hence, for example "2.00" and "2.0" should be normalized to the same
scale.

Introduce Decimal64.scaleTo(), which can be used to adjust the scale
of an existing Decimal64.

JIRA: YANGTOOLS-1440
Change-Id: Icbc215dff6d8146996c5be1040751fd1e14b6cfe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse imported checkState() 82/101282/1
Robert Varga [Wed, 25 May 2022 09:36:36 +0000 (11:36 +0200)]
Use imported checkState()

DecimalTypeBuilder already contains a static checkState() import, use
that instead of Preconditions.checkState() reference.

Change-Id: Id0d8cea3c398fc6cce6da58e9ee216360a5f0742
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoAdd AbstractConstraint.toString() 81/101281/1
Robert Varga [Wed, 25 May 2022 09:18:08 +0000 (11:18 +0200)]
Add AbstractConstraint.toString()

Resolved constraints do not have a nice toString() method, making
debugging harder than it needs to be. Add a toString() method which
exposes allowed ranges, which is usually what we need to know.

Change-Id: Ib3a8caa67a765cb29db0b2b28509f07a4c1058ce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse diamond notation for ClassValue subclass 80/101280/1
Robert Varga [Wed, 25 May 2022 08:39:29 +0000 (10:39 +0200)]
Use diamond notation for ClassValue subclass

Our Java version can now infer the type, remove redundant specifier.

Change-Id: I7829922ae645e4acc53986bd369753de0987736c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse Long.{MIN,MAX}_VALUE instead of open-coded value 76/101276/2
Robert Varga [Tue, 24 May 2022 19:18:18 +0000 (21:18 +0200)]
Use Long.{MIN,MAX}_VALUE instead of open-coded value

Java is giving us convenient constants, use them.

Change-Id: Ic62d89a60618fad1555a9651a65846f229218f0b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoImprove Decimal64 scale check 75/101275/2
Robert Varga [Tue, 24 May 2022 17:42:05 +0000 (19:42 +0200)]
Improve Decimal64 scale check

Add a proper message to the IllegalArgumentException reported.

Change-Id: Ie183dd9461540fb668de87b5f6b68a35d9bc5f07
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoFix Decimal64.toString() 73/101273/1
Robert Varga [Tue, 24 May 2022 12:21:26 +0000 (14:21 +0200)]
Fix Decimal64.toString()

intPart() does not carry the sign when the leading part is zero, hence
we need to adjust for that.

JIRA: YANGTOOLS-1438
Change-Id: I5049650b0997e6543455542d48b3f2dcdd02bc4c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse a switch expression 72/101272/1
Robert Varga [Tue, 24 May 2022 12:20:43 +0000 (14:20 +0200)]
Use a switch expression

This is just an auto-conversion to use a switch expression to initialize
initial index.

Change-Id: Ic7ed21aef2cf6a4c20733f0400163bfbf25c3a9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoSeal TypedDataSchemaNode 66/101266/2
Robert Varga [Mon, 23 May 2022 16:49:04 +0000 (18:49 +0200)]
Seal TypedDataSchemaNode

TypedDataSchemaNode is the common interface for Leaf(List)SchemaNode
and should not be used separately. Make sure we seal it.

Change-Id: Icf5592dc6e6906d9f828b9ed2090094d69527431
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoDo not override argparse4j versions 61/101261/1
Robert Varga [Mon, 23 May 2022 08:07:16 +0000 (10:07 +0200)]
Do not override argparse4j versions

odlparent is declaring versions, reuse them.

Change-Id: Ifee7e71288c1daacedb81a301404e7396a9c3235
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoSwitch yang-model-validator to argparse4j 23/101123/22
OleksandrZharov [Fri, 13 May 2022 18:13:23 +0000 (20:13 +0200)]
Switch yang-model-validator to argparse4j

Switched to use argparse4j in yang-model-validator instead of
commons-cli.

Modernized both tools interactions with argparse4j to the
latest best recommended practice.

JIRA: YANGTOOLS-1424
Change-Id: I3520d6b398831cdac0843816e857026675fde5a2
Signed-off-by: OleksandrZharov <Oleksandr.Zharov@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
2 years agoRemove unused javadoc links 51/101251/1
Robert Varga [Thu, 19 May 2022 18:29:49 +0000 (20:29 +0200)]
Remove unused javadoc links

We are not using commons-{lang,lang3,codec} nor Google Truth. Remove
javadoc links.

Change-Id: Ica3751689ee09e64fa192dba94cfaf783a0e26b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUpdate javadoc links 50/101250/1
Robert Varga [Thu, 19 May 2022 18:28:50 +0000 (20:28 +0200)]
Update javadoc links

We have some out-dated links, update them.

Change-Id: I18b539d31ff3f4385c9996f553a180c64275def5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoFix statement prerequisites and materialization 76/101176/5
Robert Varga [Tue, 17 May 2022 10:57:32 +0000 (12:57 +0200)]
Fix statement prerequisites and materialization

We are firing onStatementAdded() when copying statements, which means
that:
a) a new inference requirement may be created during inferred
   statemenent materialization
b) the inference requirement may be immediately available in effective
   model

In order to deal with this, ModifierImpl has to always go through a
bootstrap, so that it prerequisites only trigger once an action is
registered.

Furthermore InferredStatementContext needs always instantiate the map
for partial instantiations so as to deal with namespace-driven
instantiations happening while full instantiation is going on.

JIRA: YANGTOOLS-1434
Change-Id: I86dae587c1fe5804cd983c194903e1975f257408
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoEliminate HelperMethods 01/101201/2
Robert Varga [Tue, 17 May 2022 22:46:34 +0000 (00:46 +0200)]
Eliminate HelperMethods

The only caller is DataNodeContainer. Since Java 9 allows interfaces
to define private methods, move the methods there.

Change-Id: If4316f0a41ee8cfeced2bcb85534b5b46faaa43d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUpdate model.api.Status design 00/101200/1
Robert Varga [Tue, 17 May 2022 22:41:16 +0000 (00:41 +0200)]
Update model.api.Status design

Update the design of this enumeration to match DeviateKind, which
has exactly the same function. Also take advantage of the forArgument()
method in parser proper.

Change-Id: I542f6049b9e291716edcc3aaa987894cb04054b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoFix constructor argument name 99/101199/1
Robert Varga [Tue, 17 May 2022 22:33:46 +0000 (00:33 +0200)]
Fix constructor argument name

Use 'argument' for consistency.

Change-Id: I2fe192d2f443642c61076cf146884fca8d510847
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoLink to SchemaNodeIdentifier 98/101198/1
Robert Varga [Tue, 17 May 2022 22:28:18 +0000 (00:28 +0200)]
Link to SchemaNodeIdentifier

Improve documentation by having a direct link instead of @code.

Change-Id: Ia2fa040b3b4d8f06cd4025a8f6b68625cdaef541
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSimplify PatternExpression.equals() 97/101197/1
Robert Varga [Tue, 17 May 2022 22:26:57 +0000 (00:26 +0200)]
Simplify PatternExpression.equals()

Java 17 allows us to make the method much simpler, use instanceof
pattern match.

Change-Id: I0d447a5d4db7ce265277896fd24901f875fac0ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoEnforce non-null compositions 96/101196/2
Robert Varga [Tue, 17 May 2022 21:38:07 +0000 (23:38 +0200)]
Enforce non-null compositions

Expressions may not contain null values, make sure we enforce that.

Change-Id: Icd08a1c9bc2d931837f7b31362d453d794a2a0bd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRefactor IfFeaturePredicateVisitor 01/101001/10
Samuel Schneider [Fri, 6 May 2022 09:58:29 +0000 (11:58 +0200)]
Refactor IfFeaturePredicateVisitor

Refactor IfFeaturePredicateVisitor to work purely on
IfFeatureExpressionParser without use of ANTLR's visitors.

JIRA: YANGTOOLS-1396
Change-Id: I4ff988caa34a50da843fd35b8918e7b502bdf770
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRework IfFeatureExpr composition 95/101195/2
Robert Varga [Tue, 17 May 2022 21:15:07 +0000 (23:15 +0200)]
Rework IfFeatureExpr composition

Rather than using explicit returns, pass down individual factories
to a common composition method.

Change-Id: I09fe3302daeac3561056a5626d38aaf4d1ec71ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSeal IfFeatureExpr 94/101194/2
Robert Varga [Tue, 17 May 2022 20:55:44 +0000 (22:55 +0200)]
Seal IfFeatureExpr

IfFeatureExpr is not final due to implementation subclasses. Make sure
it cannot be mocked or subclassed by sealing it.

Change-Id: I9146094c9e139c4ee1a5f7fc6a59e6058356a969
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoReturn ReactorStmtCtx from ensureCompletedPhase() 87/101187/1
Robert Varga [Tue, 17 May 2022 18:44:15 +0000 (20:44 +0200)]
Return ReactorStmtCtx from ensureCompletedPhase()

We end up casting things around the verification done by
ensureCompletedPhase(). Just return the verified statement, which allows
us to tighten the signature of buffer collections.

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