yangtools.git
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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months 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>
23 months agoRemove SemVerSourceIdentifier 68/100968/3
Robert Varga [Wed, 4 May 2022 10:16:49 +0000 (12:16 +0200)]
Remove SemVerSourceIdentifier

SemVerSourceIdentifier is a needless complication necessary only for
import resolution. It has been deprecated before, remove it now.

JIRA: YANGTOOLS-1432
Change-Id: I20db2121800b121a44487f327149d4aa2b79b69e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoRemove getSemanticVersion() 67/100967/4
Robert Varga [Wed, 4 May 2022 09:51:16 +0000 (11:51 +0200)]
Remove getSemanticVersion()

OpenConfig versions are not used anywhere and have been deprecated.
Remove them.

JIRA: YANGTOOLS-1432
Change-Id: Ibb4a000dca927fa660de68fc18754057c33a4106
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoRemove ImportResolutionMode.OPENCONFIG_SEMVER 61/100961/12
Robert Varga [Tue, 3 May 2022 22:08:28 +0000 (00:08 +0200)]
Remove ImportResolutionMode.OPENCONFIG_SEMVER

OpenConfig semantic version imports are unused, remove them.

JIRA: YANGTOOLS-1432
Change-Id: I9b0370ce663f2bc27668b19766efa84960f77746
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoRemove ImportResolutionMode.SEMVER_LATEST 64/100964/4
Robert Varga [Wed, 4 May 2022 09:37:00 +0000 (11:37 +0200)]
Remove ImportResolutionMode.SEMVER_LATEST

This import mode does not have any generator which would use it. Remove
it.

JIRA: YANGTOOLS-1432
Change-Id: I060c098d97efdedd90e184912f760e0ceb8fa805
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoRemove StatementParserMode.SEMVER_MODE 62/100962/4
Robert Varga [Wed, 4 May 2022 08:23:59 +0000 (10:23 +0200)]
Remove StatementParserMode.SEMVER_MODE

Semantic version imports have been deprecated since 7.0.11, remove
the model.repo.api part of it.

JIRA: YANGTOOLS-1432
Change-Id: I0d61023a9356a89abb26c4c1f7cfc975c942677f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoDeprecate findSemanticVersion() 66/100966/1
Robert Varga [Wed, 4 May 2022 10:07:44 +0000 (12:07 +0200)]
Deprecate findSemanticVersion()

Semantic versions are deprecated pending a fresh sstart, so we do not
need findSemanticVersion().

Change-Id: I9d05d81c072472225285ecca48e51aa3e7efa309
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoDeprecate BasicCodeGenerator's SEMVER_LATEST mode 65/100965/1
Robert Varga [Wed, 4 May 2022 09:41:35 +0000 (11:41 +0200)]
Deprecate BasicCodeGenerator's SEMVER_LATEST mode

The entire class is deprecated, but make sure we mark SEMVER_LATEST
import resolution mode as deprecated for removal.

Change-Id: Ia088bf319435966acdb70ab93c56f2082d114c76
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoDeprecate getSemanticVersion() for removal 60/100960/5
Robert Varga [Tue, 3 May 2022 21:51:59 +0000 (23:51 +0200)]
Deprecate getSemanticVersion() for removal

NETMOD WG has a versioning proposal which will supersede OpenConfig,
deprecate API elements which are tied to OpenConfig versioning.

Change-Id: I2bbe1a8e6be78ecc5e911a367b0893515beaa836
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoSeal ValueNode 58/100958/1
Robert Varga [Tue, 3 May 2022 21:02:32 +0000 (23:02 +0200)]
Seal ValueNode

ValueNode is a common trait for Leaf(SetEntry)Node. Make sure javac
enforces this invariant.

Change-Id: I04a2173a0f1bddeb3c27b292b416c5e1a8a163d6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoSeal ForeignDataNode 57/100957/1
Robert Varga [Tue, 3 May 2022 20:58:04 +0000 (22:58 +0200)]
Seal ForeignDataNode

ForeignDataNode is a common trait of AnyxmlNode and AnydataNode, make
sure javac enforces that invariant.

Change-Id: Ie594e9b942bdb4744df20ac66dcf8d6f058c89c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoSeal OrderingAware 56/100956/2
Robert Varga [Tue, 3 May 2022 20:50:49 +0000 (22:50 +0200)]
Seal OrderingAware

There are only two possible orderings, make sure javac enforces that
invariant.

Change-Id: I5900a43b525d781909d74b9cb4c9f5ecd167adb4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoSeal NormalizedNodeContainer 55/100955/1
Robert Varga [Tue, 3 May 2022 20:52:42 +0000 (22:52 +0200)]
Seal NormalizedNodeContainer

NormalizedNodeContainers come in two shapes: ordered and unordered,
make sure javac enforces this invariant.

Change-Id: Id4e1807d65e1da8ead48f55493fd0797726007b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoSeal {LeafSet,Map}Node 54/100954/1
Robert Varga [Tue, 3 May 2022 20:44:21 +0000 (22:44 +0200)]
Seal {LeafSet,Map}Node

There are exactly two specializations for each of these, make sure to
seal them.

Change-Id: I551074804803c84e7e0acc38fffe1b5c9c3181a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoFix if-feature propagation for implicit case statements 36/100936/6
Peter Suna [Tue, 3 May 2022 12:33:42 +0000 (14:33 +0200)]
Fix if-feature propagation for implicit case statements

Implicit statements created during parse must not be propagated
if their child statement is not supported by features or otherwise
unavailable.

This really can only happen when we are creating an implicit declaration
on the parser side, as in other code paths the substatement is already
completely defined.

JIRA: YANGTOOLS-1431
Change-Id: I5797f09c795587c91f10c7f92a6a8c9fd2480213
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoCleanup AbstractSchemaRepositoryTest 49/100949/1
Robert Varga [Tue, 3 May 2022 18:54:30 +0000 (20:54 +0200)]
Cleanup AbstractSchemaRepositoryTest

A bit of cleanup for the base test as well as for its users. Cuts down
verbosity.

Change-Id: Iebacec662177ee3c67de8c0be2f62d3559dbff7d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoFix failure source not being reported 47/100947/6
Robert Varga [Tue, 3 May 2022 17:27:59 +0000 (19:27 +0200)]
Fix failure source not being reported

When the parser fails with a well-known exception, extract the
SourceIdentifier of the failed YANG source.

JIRA: YANGTOOLS-1428
Change-Id: Ib40b01a977131ce1d244be5bd4e67c39e04ab626
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse switch expressions for CopyType dispatch 41/100941/2
Robert Varga [Tue, 3 May 2022 15:41:20 +0000 (17:41 +0200)]
Use switch expressions for CopyType dispatch

We have exhaustive switch statements here, use expressions to make
that clear to the compiler -- improving density and ditching default
case.

Change-Id: I5ff3d4de11b39809ba209a70515fccc742ef8e03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoMove implicitDeclaredFlag 40/100940/2
Robert Varga [Tue, 3 May 2022 15:36:54 +0000 (17:36 +0200)]
Move implicitDeclaredFlag

We require JDK17, hence we can rely on improved object layout and
do not need to play as many tricks with field shadowing. Move the flag
to its sole user.

Change-Id: I514eb8fc4f9b228854450bfd4adfa284f00616a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoUse instanceof patterns in YangInstanceIdentifierWriter 39/100939/1
Robert Varga [Tue, 3 May 2022 14:58:22 +0000 (16:58 +0200)]
Use instanceof patterns in YangInstanceIdentifierWriter

We have a bit of dispatch going on here, where we end up casting things
after checking. Use patterns to ensure the casts are consistent.

Change-Id: I18ca2721f93e1926b05115263e38fc6ce9ca2659
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
23 months agoPrint out available augmentations 38/100938/2
Robert Varga [Tue, 3 May 2022 14:43:32 +0000 (16:43 +0200)]
Print out available augmentations

We seem to be facing a weird failure to look up augmentations, make
sure we report what is available.

Change-Id: Ifd9d27175bc90abfbba1a5e60935dc41cb01fc16
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoModernize testutils tests 70/100870/1
Robert Varga [Thu, 28 Apr 2022 16:44:50 +0000 (18:44 +0200)]
Modernize testutils tests

Ditch the use of Truth and use assertThrows() instead of explicit
try/catch blocks.

Change-Id: I449b187fe5fa1497fe5bf6a63367e42fa9706fa7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoClean up yang-xpath-impl warnings 54/100854/2
Robert Varga [Wed, 27 Apr 2022 19:31:45 +0000 (21:31 +0200)]
Clean up yang-xpath-impl warnings

Disconnect the DI implementation and add some javadocs.

Change-Id: I97f588d3d01a2d3f0a6a410d63c6b671550ebf4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRemove unused dependency 53/100853/1
Robert Varga [Wed, 27 Apr 2022 19:22:24 +0000 (21:22 +0200)]
Remove unused dependency

yang-xpath-impl does not use concepts, remove the declaration.

Change-Id: I313cb8c5ff183f4c457e1973078e6857ff132889
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSeal YangInstanceIdentifier 99/100799/5
Robert Varga [Mon, 25 Apr 2022 15:26:31 +0000 (17:26 +0200)]
Seal YangInstanceIdentifier

We only allow two implementations, make sure we express that to the
runtime.

Change-Id: I3e4f2208d30682a9a0d23d2e1114d9d5d790e9b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSeal ModelStatement 07/100507/12
Robert Varga [Sat, 9 Apr 2022 19:47:48 +0000 (21:47 +0200)]
Seal ModelStatement

ModelStatement can either be a DeclaredStatement or an
EffectiveStatement. Make sure we enforce that invariant.

Change-Id: Ib54d7136527b3c49fd36e813a9f1acc5b02a8894
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse pattern matching on instanceof in NormalizedNodeWriter 00/100800/4
Robert Varga [Mon, 25 Apr 2022 15:31:17 +0000 (17:31 +0200)]
Use pattern matching on instanceof in NormalizedNodeWriter

We can use a direct assignment, which makes things a tad less verbose.
Also use else-if blocks to allow for eventual exhaustiveness.

Change-Id: I68d8cbca80759807697d59d574f2ca922b1c573e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse pattern matching on instanceof in yang-common 98/100798/4
Robert Varga [Mon, 25 Apr 2022 15:21:29 +0000 (17:21 +0200)]
Use pattern matching on instanceof in yang-common

This simplifies our equals() methods quite a bit.

Change-Id: If4d0fbf6bd45c58781a93f57d005b409ed9fe629
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoModernize AntlrXPathParser 16/100516/9
Robert Varga [Sun, 10 Apr 2022 00:01:57 +0000 (02:01 +0200)]
Modernize AntlrXPathParser

Use switch expressions and instanceof matching to simplify the code.

Change-Id: Ia3d931289671c4d78de6b7938c833c350f295b6d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse instanceof expression for yang-xpath-api equality 14/100514/5
Robert Varga [Sat, 9 Apr 2022 23:48:37 +0000 (01:48 +0200)]
Use instanceof expression for yang-xpath-api equality

JDK17 allows us to ditch some amount of verbosity in equals()
implementations.

Change-Id: I3c2fdf0d688aaad3a04feb2ee4aebc69bbb4a228
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSeal YangExpr hierarchy 06/100506/9
Robert Varga [Sat, 9 Apr 2022 20:25:51 +0000 (22:25 +0200)]
Seal YangExpr hierarchy

YangExpr is a baseline interface, but it has a limited audience. Seal it
to make the hierarchy known to the compiler.

Change-Id: I1129ac2f1cf634c75d7df94a3cdb9d3b39d29274
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSeal ArgumentDefinition 05/100505/9
Robert Varga [Sat, 9 Apr 2022 19:44:54 +0000 (21:44 +0200)]
Seal ArgumentDefinition

There are only two possible subclasses. Make sure the compiler
understands that.

Change-Id: Ifa71f15c19dd0dd830ade454be04bdf380abea2b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSeal AbstractQName hierarchy 04/100504/9
Robert Varga [Sat, 9 Apr 2022 19:34:14 +0000 (21:34 +0200)]
Seal AbstractQName hierarchy

AbstractQName can either be resolved or one of the two UnresolvedQName
variants. Make sure compiler knows this by sealing them.

Change-Id: I2c3d866777bb9a1f5ab15d65ba81d132942ffed7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoSeal ItemOrder and MutationBehaviour 03/100503/9
Robert Varga [Sat, 9 Apr 2022 19:29:36 +0000 (21:29 +0200)]
Seal ItemOrder and MutationBehaviour

With JDK17 we can properly restrict the class hierarchy of these
interfaces. Also hide MutationBehaviour, as it should not leak.

Change-Id: I0681ef7a0c82abe7aa9dd7adddae69940e57011f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse switch expression to dispatch operators 12/100512/5
Robert Varga [Sat, 9 Apr 2022 23:01:09 +0000 (01:01 +0200)]
Use switch expression to dispatch operators

We are switching on an enum, hence we can ditch the default case
when we have an exhaustive expression.

Change-Id: I6df494319383d8ae39a8a42152e94c190b2f1186
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoImprove SemVer.equals() 15/100515/4
Robert Varga [Sun, 10 Apr 2022 00:14:07 +0000 (02:14 +0200)]
Improve SemVer.equals()

Use instanceof pattern to simplify the method.

Change-Id: If2f7cbdb6c6c0835eeb038a7ce5e993cddec8335
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoMake DataSchemaContextTree.NodeAndStack a record 09/100509/6
Robert Varga [Sat, 9 Apr 2022 21:01:27 +0000 (23:01 +0200)]
Make DataSchemaContextTree.NodeAndStack a record

This is a simple carrier, make it a record.

Change-Id: I92e8f81c4831137e60b3c8d4feaf5ce878f8f06b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse record for test value 11/100511/5
Robert Varga [Sat, 9 Apr 2022 22:22:36 +0000 (00:22 +0200)]
Use record for test value

We can simplify the implementation here with JDK17.

Change-Id: I16e8900f59eaba17aaf4cb36da949d73bfeb43f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoEnable Java 17 unicode blocks 90/100390/5
Robert Varga [Mon, 4 Apr 2022 21:46:56 +0000 (23:46 +0200)]
Enable Java 17 unicode blocks

Java 12 and Java 13 have expanded Unicode coverage, implementing a
number of new character blocks. Recognize them and allow them in
translation.

JIRA: YANGTOOLS-1420
Change-Id: Ic9f42b87e02d0821933a315fc54e246b1994b481
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRemove NormalizedNodes.findNode(NormalizedNode, SchemaPath) 63/100763/2
Robert Varga [Sat, 23 Apr 2022 13:10:15 +0000 (15:10 +0200)]
Remove NormalizedNodes.findNode(NormalizedNode, SchemaPath)

This method has been deprecated more than two years ago, remove it.

Change-Id: Ibf2ca6fef7b7353e3cdd5be99f739bac954f43f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUpdate yang-data-api tests 62/100762/2
Robert Varga [Sat, 23 Apr 2022 13:07:07 +0000 (15:07 +0200)]
Update yang-data-api tests

Use List.of()/Map.of() instead of Collections and Guava where
appropriate.

Change-Id: Ibb3e9948d0b48bbba0a5f18c5313c93ade01223a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoUse List.of() in DuplicateEntry 61/100761/2
Robert Varga [Sat, 23 Apr 2022 13:05:30 +0000 (15:05 +0200)]
Use List.of() in DuplicateEntry

Rather than using Collections.emptyList(), use List.of().

Change-Id: I46d88f5758642639121b68d26cacd3d700a64f8b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoCompute YangInstanceIdentifier.hashCode() lazily 47/98147/10
Robert Varga [Thu, 28 Oct 2021 11:41:05 +0000 (13:41 +0200)]
Compute YangInstanceIdentifier.hashCode() lazily

There are very few reasons to eagerly compute the hash code, let's not
do that.

JIRA: YANGTOOLS-1425
Change-Id: I0e76fa1cac539e318ee7a9bdcd28e6a6a3cbbb68
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoBump odlparent to 11.0.0-SNAPSHOT 59/100759/2
Robert Varga [Sat, 23 Apr 2022 11:17:03 +0000 (13:17 +0200)]
Bump odlparent to 11.0.0-SNAPSHOT

Pick up odlparent-11 for JDK17 work.

Change-Id: Idaadaf47505020b161bcf285e17da439d5d9375d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRemove concepts.(Checked)Builder 35/98935/5
Robert Varga [Fri, 10 Dec 2021 06:38:41 +0000 (07:38 +0100)]
Remove concepts.(Checked)Builder

The Builder concept has been deprecated in yangtools-8.0.0, remove
it now.

JIRA: YANGTOOLS-1322
Change-Id: Ie4b06fbd6f81cffb1967c73b13842b032cbb4d78
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoFix the short option for 'no-warning-for-unkeyed-lists' 23/100723/1
Sangwook Ha [Fri, 22 Apr 2022 16:13:03 +0000 (09:13 -0700)]
Fix the short option for 'no-warning-for-unkeyed-lists'

Dash "-" is not allowed in the short option string. Replace it
with 'K', a single character option consistent with others.

Having two options to control warnings on the unkeyed list,
although mutually exclusive, makes the default behavior unclear
when neither option is used.

Simplify the options by removing 'warning-for-unkeyed-lists'
while preserving the original default behavior of warning against
unkeyed lists when neither option is used.

JIRA: YANGTOOLS-1429
Change-Id: I6c37892ae7e39864420a0e6c15dd2fc1cf0ba952
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
2 years agoInvert SchemaInferenceStack.deque 17/100517/8
Robert Varga [Sun, 10 Apr 2022 14:29:16 +0000 (16:29 +0200)]
Invert SchemaInferenceStack.deque

While the use of the deque as a stack is kind of easy, it results in us
needing to operate on descendingIterator() rather than on Colleciton.
Invert the organization of the deque so that its iteration order
reflects the path from root. This has a number of benefits in terms of
code density.

JIRA: YANGTOOLS-1422
Change-Id: I442ef43cfe52842e334b48d32b901e5266041f59
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoDo not support unions with complex types 69/100569/2
Robert Varga [Wed, 13 Apr 2022 12:12:03 +0000 (14:12 +0200)]
Do not support unions with complex types

Our falling back to string representation is actively hurtful, as we end
up admitting the wrong type. We really should be treating union as a
complex type and not handle it at all, but that may break users more
than we want to in one release.

JIRA: YANGTOOLS-1427
Change-Id: I944e5869a718a768799bf334e4291cd0eb861e98
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoRemove DataNodeAggregator 19/100519/2
Robert Varga [Sun, 10 Apr 2022 15:34:18 +0000 (17:34 +0200)]
Remove DataNodeAggregator

This class is not used anywhere and has been deprecated: remove it.

Change-Id: Ie4962440ba485d086af77ebc0ff34352dfb5c24e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoBump versions to 9.0.0-SNAPSHOT 75/100575/1
Robert Varga [Thu, 14 Apr 2022 07:25:03 +0000 (09:25 +0200)]
Bump versions to 9.0.0-SNAPSHOT

This starts the next major development iteration.

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