yangtools.git
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>
22 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>
22 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>
22 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>
23 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>
23 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>
23 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>
23 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years agoIntegrate cast into verifyStatement() 86/101186/1
Robert Varga [Tue, 17 May 2022 18:39:38 +0000 (20:39 +0200)]
Integrate cast into verifyStatement()

We end up casting the statement in most cases, integrate it into
verifyStatement().

Change-Id: Ia0365c4e731e864431eeebdf95773b3da7a31774
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoShortcut statement completion 85/101185/1
Robert Varga [Tue, 17 May 2022 18:33:49 +0000 (20:33 +0200)]
Shortcut statement completion

We know we have a ReactorStmtCtx, there is no need to verify it again.

Change-Id: I15e9a4badf43f9d7004142cef0e583fa3a884140
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSwitch reported exception 20/101120/1
Robert Varga [Fri, 13 May 2022 16:39:46 +0000 (18:39 +0200)]
Switch reported exception

Use IllegalArgumentException, which probably means there is a mismatch
between the function and argument.

Change-Id: I6a1a7e7535b2b71b2a7439b2bb8975accd8f489c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRemove CheckedValue.orElseThrow(Supplier) 14/101114/1
Robert Varga [Fri, 13 May 2022 13:00:30 +0000 (15:00 +0200)]
Remove CheckedValue.orElseThrow(Supplier)

This method has been deprecated, remove it.

Change-Id: Iacb84d93ffedcd000157a35807a9a9951553bbf1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoStabilize and update EffectiveIdentityTest 80/101080/2
Robert Varga [Wed, 11 May 2022 15:54:23 +0000 (17:54 +0200)]
Stabilize and update EffectiveIdentityTest

The order of exceptions can vary based on resolution order. Make sure we
sort them and make assertions on that. Also improve other assertions in
this test suite.

Change-Id: I2d8f6f7848f5bd22abbb0284aa4780aec60bd0d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse AbstractUnqualifiedStatementSupport 73/101073/2
Robert Varga [Wed, 11 May 2022 12:26:16 +0000 (14:26 +0200)]
Use AbstractUnqualifiedStatementSupport

We have a centralized way of parsing arguments here, use that instead of
rolling our own for both modules and submodules.

JIRA: YANGTOOLS-837
Change-Id: I9e4eab0b708dd39111fbeac9015eff2fbcd6784f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoImprove IdentityrefTypeDefinition 65/101065/3
Robert Varga [Wed, 11 May 2022 11:37:42 +0000 (13:37 +0200)]
Improve IdentityrefTypeDefinition

Base identities are guaranteed to be non-null, annotate that and
use ImmutableSet for internal implementation.

Change-Id: I8e2356bd63a5cb41d4b2a01103a1444bd4e82ef4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoFix UsesNode.getAugmentations() 63/101063/1
Robert Varga [Wed, 11 May 2022 11:25:23 +0000 (13:25 +0200)]
Fix UsesNode.getAugmentations()

The collection we are returning is guaranteed to not contain null
elements, annotate that.

Change-Id: I8b516c4de69f06c80284b037cefa48c6fa792f4e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse local variable type inference 61/101061/2
Robert Varga [Wed, 11 May 2022 11:07:22 +0000 (13:07 +0200)]
Use local variable type inference

Eclipse has a number of warnings which boil down to capturing the
nullability contract. Use a simple 'var' to reduce verbosity and fix a
number of warnings.

Change-Id: I607a77e0c90d14cb51ecbd0bf5b11ab190d2d1f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse 'var' in Bug4456Test 60/101060/1
Robert Varga [Wed, 11 May 2022 10:33:05 +0000 (12:33 +0200)]
Use 'var' in Bug4456Test

This cleans up a few warnings reported by Eclipse.

Change-Id: I9359acc87bc5a01228fd3bf952911a1955d04733
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoModerinize DeviateKind documentation 58/101058/1
Robert Varga [Tue, 10 May 2022 21:10:54 +0000 (23:10 +0200)]
Moderinize DeviateKind documentation

Expand the documentation to include a reference to RFC7950. Also
guarantee @NonNull return from getKeyword() and rename it to argument().
Provide static factory methods for acquiring an enum object for an
argument.

Change-Id: I290631863394545f7240eeb66eb5b6dd1090d5ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse text blocks in YT1433Test 56/101056/1
Robert Varga [Tue, 10 May 2022 19:43:50 +0000 (21:43 +0200)]
Use text blocks in YT1433Test

We have two multi-line concatenations here, just use text blocks
instead.

Change-Id: I837554506c305ee8b608da0f5be245c9a8ac0538
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoFix nested augmentations 35/101035/11
Robert Varga [Tue, 10 May 2022 06:01:21 +0000 (08:01 +0200)]
Fix nested augmentations

When we are entering an augmentation, we need to look at the effective
instantiation. For DataNodeContainers that means using
EffectiveAugmentationSchema to get the correct filter, for choices we do
not have a utility, so just retain the same parent.

JIRA: YANGTOOLS-1433
Change-Id: I0aa36499a5bcf6088be5b49b79d202f8985f5eca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse a text block in YT1411Test 55/101055/1
Robert Varga [Tue, 10 May 2022 19:31:56 +0000 (21:31 +0200)]
Use a text block in YT1411Test

We have a multiline concatenation, use a text block instead.

Change-Id: I328aa76fe539db7b37f9e17e0884e2e4a29c7ad9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoReformulate YangInstanceIdentifierWriterTest 51/101051/2
Robert Varga [Tue, 10 May 2022 16:32:48 +0000 (18:32 +0200)]
Reformulate YangInstanceIdentifierWriterTest

We have SchemaNode mocking going on here, which we really do not need --
just define the corresponding models and use YANG parser to create the
underlying schema.

JIRA: YANGTOOLS-1433
Change-Id: I861df0d4170737e4ecac0f64b6016d5f259332af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoFix pom.xml format 50/101050/2
Robert Varga [Tue, 10 May 2022 16:27:39 +0000 (18:27 +0200)]
Fix pom.xml format

We should have four spaces here.

Change-Id: Ie9a7adeb7add53825ae5409f72e67b12ac5e9c7e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse text blocks in YangInstanceIdentifierWriterTest 52/101052/2
Robert Varga [Tue, 10 May 2022 18:08:49 +0000 (20:08 +0200)]
Use text blocks in YangInstanceIdentifierWriterTest

We have JDK17, we can use text blocks for multiline strings.

Change-Id: I0b130fcd183ecd3d3b8ddf1fdb9862847af92244
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRemove unused dependency 16/101016/1
Robert Varga [Mon, 9 May 2022 11:44:32 +0000 (13:44 +0200)]
Remove unused dependency

yang-repo-spi does not need yang-common, remove the dependency.

Change-Id: Idbb3f7f75bf50e0580c843a490b9a3db37beaf5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoFix OpenConfigConstants 08/101008/1
Robert Varga [Mon, 9 May 2022 08:39:19 +0000 (10:39 +0200)]
Fix OpenConfigConstants

The name of the module is not correct, it should be
openconfig-extensions.

Change-Id: If38676aa836e283349f60d9c630f60f4dba85116
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRemove RevisionSourceIdentifier 98/100998/13
Robert Varga [Wed, 4 May 2022 23:59:19 +0000 (01:59 +0200)]
Remove RevisionSourceIdentifier

SourceIdentifier is a well-understood contract, of which we have only
one implementation. Merge RevisionSourceIdentifier with
SourceIdentifier, turning SourceIdentifier into a record in the process
of doing so.

JIRA: YANGTOOLS-837
Change-Id: If223fb0c3daa2dd6eb15e4d01bb6091c9055ab58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSwitch Import/Include/BelongsTo statements to use Unqualified 00/101000/8
Robert Varga [Thu, 5 May 2022 16:09:38 +0000 (18:09 +0200)]
Switch Import/Include/BelongsTo statements to use Unqualified

Using String is not entirely accurate, as it is missing required
validation. Make sure we force validation by switching the argument
to UnresolvedQName.Unqualified.

This will ease up integration with SourceIdentifier, which in turn is
required to make varied conformance work with explicit RFC8525
specification.

JIRA: YANGTOOLS-837
Change-Id: If320b1f64f2e1bff9a2086137af0d814bbf03f2a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoIntroduce {Qualified,Unqualified}.of() 04/101004/2
Robert Varga [Sun, 8 May 2022 21:57:59 +0000 (23:57 +0200)]
Introduce {Qualified,Unqualified}.of()

We are proliferating use on Unqualified quite a bit and since it is a
visible class, we should have a nice way of instantiating it. Introduce
static factory of() methods for both alternatives.

Change-Id: Ib19077861678d8e84cf67c517a382b758186a266
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoFixup yang-parser-api module a bit 97/100997/1
Robert Varga [Thu, 5 May 2022 00:01:05 +0000 (02:01 +0200)]
Fixup yang-parser-api module a bit

Do not rely on concepts being pulled in, require them explicitly.

Change-Id: Ia0add6933624a650910064459075d7f5b171e55f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoStatementSupport is not a StatementDefinition 96/100996/2
Robert Varga [Wed, 4 May 2022 21:10:35 +0000 (23:10 +0200)]
StatementSupport is not a StatementDefinition

Differentiate between StatementSupport and StatementDefinition, so as
to separate their lifecycle.

Change-Id: Id96ece0e6890b1aa1463e5f4e9a378fa3f5949fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoMove OpenConfigVersion support 95/98095/26
Robert Varga [Thu, 21 Oct 2021 09:15:40 +0000 (11:15 +0200)]
Move OpenConfigVersion support

We are no longer using semantic versions to resolve linkage. Move
statement support to openconfig-parser-support.

JIRA: YANGTOOLS-1432
Change-Id: I144cd2a1040c264b9c6bfafceb95ef5a77e09d90
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>