yangtools.git
3 years agoMigrate getDataChildByName() users 86/94086/5
Robert Varga [Mon, 7 Dec 2020 09:24:48 +0000 (10:24 +0100)]
Migrate getDataChildByName() users

These users are using getDataChildByName() in its nullable capacity,
migrate them to dataChildByName().

JIRA: YANGTOOLS-1183
Change-Id: Id2cdf95804b1faf6189863de9f96253ab459ed6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRework NormalizedNode type hierarchy 13/93813/49
Robert Varga [Thu, 12 Nov 2020 18:01:30 +0000 (19:01 +0100)]
Rework NormalizedNode type hierarchy

Rework the NormalizedNode model to split identifier and value,
using overrides rather than generics. This cuts down complexity
quite a bit and makes the interface much more friendly.

This allows us to fix some of the sins in the overall NormalizedNode
hierarchy:

0) Use to generics is minimized:
- NormalizedNode, DataNodeContainer are no longer generic
- other constructs either gained or lost an argument, with losses
  being more prevalent.

1) yang.data.api.OrderingAware provides an explicit tie to order-by
   statement

2) NormalizedNodeContainer is split into two concepts:
- DistinctNodeContainer, allowing PathArgument lookups
- OrderedNodeContainer, allowing offset-based lookups and implying
  OrderingAware.User

3) MapNode is likewise split into two nodes based on Ordering:
- UserMapNode, which both DistinctNodeContainer and
  OrderedNodeContainer
- SystemMapNode, which is a plain OrderingAware.System
  DistinctNodeContainer

3) LeafSet follow the same split as MapNode

JIRA: YANGTOOLS-1022
Change-Id: I49c58850f565182826f5a8e1fc5b58cffb4a7d47
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSelect copyPolicy for each StatementSupport class 50/94050/5
miroslav.kovac [Fri, 4 Dec 2020 14:54:14 +0000 (15:54 +0100)]
Select copyPolicy for each StatementSupport class

Since we want to minimaze amount of copping that we do
we need to set the appropriate copyPolicy for each
StatementSupport class separately

JIRA: YANGTOOLS-1164
Change-Id: I128bfb44a1dffb4620b2f8aec4fef6a953d85c89
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove findSubstatementArgument()/hasSubstatement() to BoundStmtCtx 78/94078/4
Robert Varga [Sun, 6 Dec 2020 12:49:28 +0000 (13:49 +0100)]
Move findSubstatementArgument()/hasSubstatement() to BoundStmtCtx

Since we have StmtContext and BoundStmtCtx unified, move
hasSubstatement() into BoundStmtCtx and implement it in
ReactorStmtCtx. This allows better access to this functionality.

JIRA: YANGTOOLS-1157
Change-Id: I33eaba254c82e4b8e0152c03d8da91fef4453f63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd UnqualifiedQName.tryCreate() 85/94085/2
Robert Varga [Sun, 6 Dec 2020 12:37:39 +0000 (13:37 +0100)]
Add UnqualifiedQName.tryCreate()

This a better approach to performing a lazy check, as it captures
the valid string in a well-known construct.

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

3 years agoMake DataNodeContainer.dataChildByName() non-default 81/94081/5
Robert Varga [Sun, 6 Dec 2020 16:19:41 +0000 (17:19 +0100)]
Make DataNodeContainer.dataChildByName() non-default

Switch implementations, so that we provide findDataChildByName()
as a default method and require a nullable lookup.

JIRA: YANGTOOLS-1183
Change-Id: I0e5ba2373b4ec6a4e1d6c8e7923e05954b2275c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCreate all effective statements path Nullable 20/94020/6
miroslav.kovac [Thu, 3 Dec 2020 13:36:10 +0000 (14:36 +0100)]
Create all effective statements path Nullable

Every effective statement that is saving path
may have this variable set to null if the
system property is set to forbid path.

JIRA: YANGTOOLS-1071
Change-Id: I7726f40f63f1bd2cf25cf2f8f85bf02826eb375e
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
3 years agoAdd DataNodeContainer.dataChildByName() 80/94080/2
Robert Varga [Sun, 6 Dec 2020 13:05:18 +0000 (14:05 +0100)]
Add DataNodeContainer.dataChildByName()

This is a non-deprecated equivalent of getDataChildByName(), allowing
easy migration of nullable users.

JIRA: YANGTOOLS-1183`
Change-Id: Iaf2336fdbfb6533fe759ea4a359b7458e20c79fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix implementation nullness guarantees 79/94079/1
Robert Varga [Sun, 6 Dec 2020 16:16:39 +0000 (17:16 +0100)]
Fix implementation nullness guarantees

We are promising @NonNull in the contract, make sure implementations
do the same.

Change-Id: Ib895ffedc48c221ab4a98a4a318101bc3df46bc4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use StmtContext for ThirdPartyNamespace 75/94075/1
Robert Varga [Sat, 5 Dec 2020 16:14:13 +0000 (17:14 +0100)]
Do not use StmtContext for ThirdPartyNamespace

This is a simple demo/test, use the typical inference/build
argument passing pattern, eliminating the need to deal with nasty
rabbits.

Change-Id: I3783da94e110bac94a17f6e7db0d2086c1630d37
JIRA: YANGTOOLS-1186
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix AugmentImplicitHandlingNamespace 74/94074/1
Robert Varga [Sat, 5 Dec 2020 14:54:35 +0000 (15:54 +0100)]
Fix AugmentImplicitHandlingNamespace

We are dropping a simple marker for ourselves, hence make the namespace
keyed by Empty and only statementLocal.

JIRA: YANGTOOLS-1186
Change-Id: Ifd14cbe5f8ca22c29fad7efd039a73d4697441aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not access TypeNamespace during build 73/94073/2
Robert Varga [Sat, 5 Dec 2020 13:31:04 +0000 (14:31 +0100)]
Do not access TypeNamespace during build

Rather than accessing TypeNamespace use a statement-local namespace
to store the reference to the type (which we ignored so far). This
allows us to wipe TypeNamespace when RootStatementContext is done.

JIRA: YANGTOOLS-1198
Change-Id: I017673ae6314f86ea4e9562a5072a7e7b2865649
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRefactor YT838Test 72/94072/1
Robert Varga [Sat, 5 Dec 2020 13:34:30 +0000 (14:34 +0100)]
Refactor YT838Test

We are checking for thrown exceptions here, make use of assertThrows()
and hamcrest to make the reports more understandable.

Change-Id: Ia44be0835897300b86e7896cd7b441f7ccb8fb5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not access TypeNamespace during declared build 71/94071/1
Robert Varga [Sat, 5 Dec 2020 13:27:37 +0000 (14:27 +0100)]
Do not access TypeNamespace during declared build

We have a shadowing check here which is being executed at
buildDeclared() time. Move the check into an inference action,
so that we do not even go to statement build if it is violated.

JIRA: YANGTOOLS-1198
Change-Id: Ibb5d121862bc2d822c5919a3233ae790412e53f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not access GroupingNamespace during effective build 53/94053/4
Robert Varga [Fri, 4 Dec 2020 17:02:36 +0000 (18:02 +0100)]
Do not access GroupingNamespace during effective build

There are two places which are accessing GroupingNamespace during
statement build:

AbstractGroupingStatementSupport.buildDeclared() performs a check
for namespace conflict. This is better done through an inference
action in FULL_DECLARATION of root model, when we can check whether
there is a conflict -- before we ever get to build statements.

UsesStatementSupport is searching namespaces to locate its source
to build its effective model -- to satisfy
UsesNode.getSourceGrouping(). This is better done by remembering
the source grouping's context in a statement-local namespace
and then pick it up when needed.

The two changes together allow us to sweep GroupingNamespace at
the end of RootStatementContext's build.

JIRA: YANGTOOLS-1197
Change-Id: I3a75ad92aeffeeed279466fffcf4402b17ee1d09
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd TypeNamespace cleaning FIXMEs 52/94052/1
Robert Varga [Fri, 4 Dec 2020 16:31:23 +0000 (17:31 +0100)]
Add TypeNamespace cleaning FIXMEs

Place FIXMEs that need to be addressed to resolve this issue.

JIRA: YANGTOOLS-1198
Change-Id: Ib77ca7f6acc3dba6389bba01428e7fbd0b290a2b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd GroupingNamespace cleaning FIXMEs 51/94051/1
Robert Varga [Fri, 4 Dec 2020 16:28:46 +0000 (17:28 +0100)]
Add GroupingNamespace cleaning FIXMEs

Drop FIXMEs that need to be addressed.

JIRA: YANGTOOLS-1197
Change-Id: I24e7e9c5ebedf41c22a102782a1d3bfe9b63f1d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd DataSchemaNode.effectiveConfig() 00/86900/8
Robert Varga [Fri, 4 Dec 2020 11:48:42 +0000 (12:48 +0100)]
Add DataSchemaNode.effectiveConfig()

DataSchemaNode.isConfiguration()'s boolean return is inaccurate
modeling: a DataSchemaNode can be inside a top-level grouping, in
which case it does not have its 'config' defined.

Add effectiveConfig() which accurately reflects whether there is
a 'config' statement in effect or not.

JIRA: YANGTOOLS-1063
Change-Id: I2314aaa169a591cce419b925a965cbed118f249e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake EffectiveStmtCtx.effectiveConfig() accurate 23/94023/4
Robert Varga [Fri, 4 Dec 2020 10:27:34 +0000 (11:27 +0100)]
Make EffectiveStmtCtx.effectiveConfig() accurate

There are four (rather than two) states effectiveConfig() can be in
and statement implementations need to account for this. Capture the
possibilities in EffectiveConfig enumeration and adjust users.

JIRA: YANGTOOLS-1063
Change-Id: I724a8bd65ca836ddc48e3579d985afc6baf271f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix YangModeledAnyxmlEffectiveStatementImpl.isMandatory() 47/94047/2
Robert Varga [Fri, 4 Dec 2020 13:27:21 +0000 (14:27 +0100)]
Fix YangModeledAnyxmlEffectiveStatementImpl.isMandatory()

We have a bug in forwarding here, fix that.

Change-Id: I6f71c2df71b4922a45edc41ac19a8fdb71122b3e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoLower NamespaceStorageSupport logging 22/94022/1
Robert Varga [Fri, 4 Dec 2020 10:20:28 +0000 (11:20 +0100)]
Lower NamespaceStorageSupport logging

We really do not need to flood tests with information about namespaces
being swept, silence those logs.

Change-Id: Ie4bd751851e8c3cb458c348e0cad30fd1be9037a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRequire SchemaTreeEffectiveStatement in OnDemandSchemaTreeStorageNode 89/93789/8
Robert Varga [Thu, 5 Nov 2020 16:16:01 +0000 (17:16 +0100)]
Require SchemaTreeEffectiveStatement in OnDemandSchemaTreeStorageNode

This storage concept is inherently tied to schema tree. Let's express
that in its API.

Change-Id: I5cb736c7752437fa53003e7f98a11be14a415cc2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd parent refcount cache 88/93988/18
Robert Varga [Wed, 2 Dec 2020 07:58:55 +0000 (08:58 +0100)]
Add parent refcount cache

The idea here is that we check with references towards root quite
often. Since we have a one-byte gap in StatementContextBase, we can
use it to track knowledge of what parent refs look like -- and
side-step a lot of pointer chasing on our way to root.

JIRA: YANGTOOLS-1184
Change-Id: I6342292d8f6675ef446dca8410bb859e2d6f230c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoIntegrate {Inference,Source}Exception with CommonStmtCtx 15/94015/7
Robert Varga [Thu, 3 Dec 2020 02:16:12 +0000 (03:16 +0100)]
Integrate {Inference,Source}Exception with CommonStmtCtx

We rarely need StatementSourceReference and we already define
a CommonStmtCtx which can provide it at almost any moment. Migrate
users, so that the reference is accessed only when needed.

This changes the balance of access, so that we may get away with
forwarding this through InferredStatementContext's prototype.

JIRA: YANGTOOLS-1194
Change-Id: I24e97cf10c68415caaa913014a9b6620f43cd94d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoTrim down ReplicaStatementContext 94/93994/8
Robert Varga [Wed, 2 Dec 2020 14:43:35 +0000 (15:43 +0100)]
Trim down ReplicaStatementContext

Shuffle around the code and class hierarchy to make
ReplicaStatementContext inherit only ReactorStmtCtx. This reduces
the size of the instance by about one half.

JIRA: YANGTOOLS-1184
Change-Id: Ibefc13a6302dd5799839af45bf47e26d232fb563
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCentralize SchemaNode.getPath() dispatch 35/93935/15
Michal Banik [Thu, 26 Nov 2020 12:21:50 +0000 (13:21 +0100)]
Centralize SchemaNode.getPath() dispatch

Our handling of SchemaPath is quite scattered. This patch makes
it easier to reason about what is going on where.

JIRA: YANGTOOLS-1071
Change-Id: Ia90976635223d2347861554e9a59c35f190b7a5d
Signed-off-by: Michal Banik <michal.banik@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake SchemaNode.getPath() a default method 10/94010/2
Robert Varga [Wed, 2 Dec 2020 22:26:30 +0000 (23:26 +0100)]
Make SchemaNode.getPath() a default method

Make sure implementations do not have to implement getPath() as we
can just have a default method throwing UnsupportedOperationException.

Change-Id: I3490d6d706113ea14ee3f4181a7ba827380c8181
JIRA: YANGTOOLS-1071
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoReduce StmtCtx proliferation 14/94014/1
Robert Varga [Thu, 3 Dec 2020 01:49:40 +0000 (02:49 +0100)]
Reduce StmtCtx proliferation

We only need a CommonStmtCtx, make sure we start the migration.

Change-Id: Ib9ea845fa25d19f761600eaab28a636f17e0b852
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse EffectiveStmtCtx.Current in ExtensionStatementSupport 13/94013/1
Robert Varga [Thu, 3 Dec 2020 01:47:00 +0000 (02:47 +0100)]
Use EffectiveStmtCtx.Current in ExtensionStatementSupport

Now that identity works again, we can safely ditch the escape
hatch and operate on EffectiveStmtCtx.

JIRA: YANGTOOLS-1185
Change-Id: I60a2eb98136faabe1a73b51b4f4f5a8556b56e7e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse statementContextBase when creating effecive 02/94002/6
miroslav.kovac [Wed, 2 Dec 2020 10:21:42 +0000 (11:21 +0100)]
Use statementContextBase when creating effecive

StatementContextBase is now implementing EffectiveStmtCtx.Current
and hence it can be used in createEffective. This saves us an object
allocation during buildEffective() time.

JIRA: YANGTOOLS-1185
Change-Id: Iffc02f7aa222070d750dbb9628894a891fb17a0c
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd BoundStmtCtxCompat 87/93987/13
miroslav.kovac [Tue, 1 Dec 2020 14:20:53 +0000 (15:20 +0100)]
Add BoundStmtCtxCompat

This is a compatibility interface between StmtContext and
EffectiveStmtCtx.Current, hosting the declared instance (for now).

JIRA: YANGTOOLS-1185
Change-Id: Ie1526b7447d9935c8f21910cd4aff298a385103f
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
3 years agoIntroduce NamespaceStmtCtx 86/93986/11
miroslav.kovac [Tue, 1 Dec 2020 13:55:34 +0000 (14:55 +0100)]
Introduce NamespaceStmtCtx

We have a few namespace access methods, make sure we encapsulate
them into a NamespaceStmtCtx and expose them from both
StmtContext and EffectiveStmtCtx.Current.

JIRA: YANGTOOLS-1185
Change-Id: I5c13406b96ab3735761749b900c244ad555f8730
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCopyHistory and yangVersion merge 84/93984/6
miroslav.kovac [Tue, 1 Dec 2020 13:16:34 +0000 (14:16 +0100)]
CopyHistory and yangVersion merge

history and getCopyHistory together with yangVersion and
getRootVersion can be merged since it is used in both
StmtContext and EffectuveStmtCtx.Current.

Since a few methods still do not have a proper new name,
introduce StmtContextCompat to host these.

JIRA: YANGTOOLS-1185
Change-Id: I7b63a96e6d00ef3378544ce9bd0970f3857e7358
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoEliminate ReplicaStatementContext.haveRef 09/94009/2
Robert Varga [Wed, 2 Dec 2020 14:10:51 +0000 (15:10 +0100)]
Eliminate ReplicaStatementContext.haveRef

This is a very costly boolean, costing us on alignment in the range
of 4-16 bytes. As it turns out we can reuse the boolean used for
fullyDefined(), so do that and reduce instance size.

JIRA: YANGTOOLS-1184
Change-Id: I59a6227c1715549472358e3ca8f003d800377322
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemost StatementContextBase.schemaPath() 08/94008/2
Robert Varga [Wed, 2 Dec 2020 13:39:02 +0000 (14:39 +0100)]
Remost StatementContextBase.schemaPath()

We are still suporting this mechanics, hence move it to
ReactorStmtCtx, allowing it to be reused without StatementContextBase.

JIRA: YANGTOOLS-1184
Change-Id: Ife7fd573e14415e78fd45663a40c904d702a05b1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use exceptions for branching 76/93976/4
Robert Varga [Mon, 30 Nov 2020 16:30:24 +0000 (17:30 +0100)]
Do not use exceptions for branching

UnrecognizedEffectiveStatementImpl is mis-using
StmtContextUtils.qnameFromArgument() to attempt to create a QName,
suppressing reported exceptions.

Use a custom-tailored lookup, which utilizes
AbstractQName.isValidLocalName() and thus side-steps exceptions.

JIRA: YANGTOOLS-1191
Change-Id: Iecea9f446730e4e7840b962a95844ce5128dfb9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove flags to ReactorStmtCtx 07/94007/1
Robert Varga [Wed, 2 Dec 2020 13:28:30 +0000 (14:28 +0100)]
Move flags to ReactorStmtCtx

We have a bunch of bitwise flags we are using for various
inference details. Unfortunately them being placed in
StatementContextBase and ReactorStmtCtx layout result in 8 bytes
being lost on 64bit w\o compressed oops.

Move the flags and their methods to ReactorStmtCtx, reducing
InferredStatementContext footprint from 160 bytes to 152 bytes
(i.e. 5%).

JIRA: YANGTOOLS-1184
Change-Id: I0c9787795fc67c1e979132f9244f06a7a7e3dc3e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove more StatementContextBase methods 06/94006/1
Robert Varga [Wed, 2 Dec 2020 12:57:45 +0000 (13:57 +0100)]
Move more StatementContextBase methods

ReactStmtCtx is overtaking the role of baseline implementation,
hence we move forwarder final methods there.

JIRA: YANGTOOLS-1184
Change-Id: I4ac8b13b29ddd5db7b7960ae6e271fcd223a09d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove effectiveInstance to ReactorStmtCtx 05/94005/1
Robert Varga [Wed, 2 Dec 2020 12:47:14 +0000 (13:47 +0100)]
Move effectiveInstance to ReactorStmtCtx

This is part of our common mechanics which integrates with refcounts.
Move the field down to ReactorStmtCtx, simplifying interactions a bit.

JIRA: YANGTOOLS-1184
Change-Id: Ibf48b4fbf47d710ed642ef525fceefe5f14719c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove ReactorStmtCtx.parentStmtCtx() 04/94004/1
Robert Varga [Wed, 2 Dec 2020 12:36:59 +0000 (13:36 +0100)]
Remove ReactorStmtCtx.parentStmtCtx()

We have the same facility in StatementContextBase.getParentContext(),
hence we can directly reuse it.

JIRA: YANGTOOLS-1184
Change-Id: Ie0d13fc86e50764a5e27ed0cb3d1d5731ddf6116
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake sweep-on-decrement more aggressive 01/94001/2
Robert Varga [Wed, 2 Dec 2020 09:38:43 +0000 (10:38 +0100)]
Make sweep-on-decrement more aggressive

We are holding off on cleaning if we have a parent, which effectively
means we not start sweeping children until that process is initiated
from parent.

This is needlessly conservative: we should actually be checking parent
refcount and trigger cleanup as soon as we observe no explicit
references.

JIRA: YANGTOOLS-1184
Change-Id: Ief30aa03b760116540d77038fb8c78fd5b0daf5a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSweep child->parent relationships more quickly 98/93998/7
Robert Varga [Tue, 1 Dec 2020 22:33:10 +0000 (23:33 +0100)]
Sweep child->parent relationships more quickly

Sweep logic currently does not kick in until the root statement of
a particular source is completely built. This leads to us retaining
all of the state until that moment, at which point we mass-release
everything.

This is caused by us being needlessly conservative in deciding when
to start sweeping our parents.

Replace ReactorStmtCtx.noParentRefs() with noParentRefcount(), which
disregards noImplicitRef(). This allows us to start sweeping as
soon as we buildEffective() any child of a subtree, propagating
towards parent -- which is safe, since there can be no new incoming
explicit references.

JIRA: YANGTOOLS-1184
Change-Id: I97feeb65c270b1e7abceb99b94938593cf2e9abc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd a refcount mechanism for substatements 36/93936/42
Robert Varga [Thu, 26 Nov 2020 12:39:02 +0000 (13:39 +0100)]
Add a refcount mechanism for substatements

We need to defer cleaning substatements until there is no way
they could be referenced again. This can happen, for example,
when we make a copy through uses: source grouping can be built
independently, but needs to retain its effective statements
until all its copies are built as well.

This expands InferredStatementContext 8 bytes, which we will need
to reclaim/justify somehow.

At this point we end up with negligble post-build residue, but
peak usage remains high (and goes up a bit). We'll build on top
of that in further patches.

JIRA: YANGTOOLS-1184
Change-Id: I5d26846ee1a5ce705671d9e66d45137a3d1084cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRefactor ConfigListWarningNamespace 97/93997/3
Robert Varga [Tue, 1 Dec 2020 21:55:19 +0000 (22:55 +0100)]
Refactor ConfigListWarningNamespace

We are using a boolean to suppress warnings for particular statements
here. There are two problems here:

1. we can end up accessing the namespace after originalCtx has been
   built, which is not nice, as it cannot be swept
2. we make poor use of namespace's capabilities (we just hold a boolean)

Make ConfigListWarningNamespace a global namespace, hence it end up
being hosted BuildGlobalContext, hence is always accessible.

Furthermore make the connection that a StatementSourceReference
is good enough alias for the statement, hence we can just store those,
reducing the number of places where StmtContexts can lurk.

JIRA: YANGTOOLS-1184
Change-Id: I31629f73e095301617254be30e10a695d13309ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCleanup ListKeysTest 95/93995/1
Robert Varga [Tue, 1 Dec 2020 21:41:57 +0000 (22:41 +0100)]
Cleanup ListKeysTest

Use assertThrows()/assertThat() to make the test simpler and more
expressive.

Change-Id: I088cd411b1e8ee0e00491a187d7b5881f494cbbb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFire AbstractPrerequisite listeners as soon as they resolve 85/93985/2
Robert Varga [Tue, 1 Dec 2020 13:42:15 +0000 (14:42 +0100)]
Fire AbstractPrerequisite listeners as soon as they resolve

We seem to be stuck with listeners not firing, leaving references
which need to be cleared. Ensure we fire phase listeners as soon
as they are satisfied -- repurposing tryApply() for its logical
purpose.

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

3 years agoTag internally-reused statements 77/93977/1
Robert Varga [Mon, 30 Nov 2020 16:33:22 +0000 (17:33 +0100)]
Tag internally-reused statements

This call site was missed by the previous audit, make sure we
create a replica of the reused statement.

JIRA: YANGTOOLS-1190
Change-Id: I08b0e1cd7b3697ff1261fc7bb7984c1223959ad3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSearch effective statements instaead of StmtContexts 73/93973/2
Robert Varga [Mon, 30 Nov 2020 07:50:33 +0000 (08:50 +0100)]
Search effective statements instaead of StmtContexts

When we are searching for the appropriate namespace/prefix, we want
to be referring to the effective statements we have at hand rather
than dropping back to StmtContext.

JIRA: YANGTOOLS-1186
Change-Id: Ic2c3c94498ef11f807a56e3dd533b31c28c97f26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake Mutable.replicaAsChildOf() non-default 70/93970/5
Robert Varga [Sun, 29 Nov 2020 21:50:22 +0000 (22:50 +0100)]
Make Mutable.replicaAsChildOf() non-default

We really want to strongly bind to this contract, make sure it is
non-default.

Change-Id: I6616567abf3800f0a4ec91b43d256460f66e7bcc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoIsolate statement reuse sites 69/93969/7
Robert Varga [Sun, 29 Nov 2020 21:16:08 +0000 (22:16 +0100)]
Isolate statement reuse sites

Augment wants to do something atypical: it assumes its state cannot
be further inferred into at both source and target context place and
it wants the same EffectiveStatement to emerge at both places.

This violates SchemaPath rules on one side of the equation or the
other, but seems to work for the intended case.

As it turns out, we are already doing something similar in the reactor,
but here we are taking the guidance of StatementSupport in the form
of CopyPolicy.

Make sure all users of this mechanics are calling into
Mutable.replicaAsChildOf(), where the reactor can properly capture
the lifecycle transition. This includes 'deviate' statement as well.

JIRA: YANGTOOLS-1190
Change-Id: Ic0032c50a1abbc65265dcbc038f72598761e9c36
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCase statement's config is inherited from DataSchemaNode 72/93972/1
Robert Varga [Sun, 29 Nov 2020 23:14:23 +0000 (00:14 +0100)]
Case statement's config is inherited from DataSchemaNode

The check here goes through StmtContext.allSubstatementsStream()
when it already has all the substatements built. Look at the
effective children rather than contexts.

JIRA: YANGTOOLS-1186
Change-Id: Iff835d781e182c7987ad50802b62a46cc72a2d59
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClean up NameCollisionWithinCaseTest 71/93971/2
Robert Varga [Sun, 29 Nov 2020 23:04:56 +0000 (00:04 +0100)]
Clean up NameCollisionWithinCaseTest

Use assertThrows() to properly catch exceptions, cleaning up related
Sonar complaints.

Change-Id: I23a956f008db6ca53329627ef190fc74b0055a33
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSplit out AugmentInferenceAction 62/93962/5
Robert Varga [Fri, 27 Nov 2020 17:44:26 +0000 (18:44 +0100)]
Split out AugmentInferenceAction

We will need to specialize augment inference to do the right thing
in all circumstances. This patch splits it out into a standalone
class, so it is clearer what is being used where.

JIRA: YANGTOOLS-1190
Change-Id: Ied0ed3bd12c9639a45435c8f0ab615df844012d6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMore deprecated method migration 63/93963/2
Robert Varga [Fri, 27 Nov 2020 18:20:46 +0000 (19:20 +0100)]
More deprecated method migration

Sweep extension supports for use of deprecated methods.

Change-Id: Ibe405e78f499cc1c1f213b02363a34fd2e224c55
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoEnforce augment statement argument well-formedness 61/93961/3
Robert Varga [Fri, 27 Nov 2020 16:02:43 +0000 (17:02 +0100)]
Enforce augment statement argument well-formedness

'augment' statement has dual use, depending on where it is declared.
Each use requires a different schema node identifier:
- plain augment requires SchemaNodeIdentifier.Absolute
- uses/augment requires SchemaNodeIdentifier.Descendant

Make sure we enforce proper parsing, so that our argument will end
up being correctly captured (and can be used for further reasoning).

JIRA: YANGTOOLS-1189
Change-Id: I4e628fd1aee29e103a045cfe90bae58f91ce32ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoEliminate AbstractEffectiveModule.schemaTreeNamespace 57/93957/2
Robert Varga [Fri, 27 Nov 2020 10:29:19 +0000 (11:29 +0100)]
Eliminate AbstractEffectiveModule.schemaTreeNamespace

We already have DefaultWithDataTree.WithSubstatements's indices,
hence there is no point in re-doing the same work.
Eliminate duplication and defer to our superclass.

JIRA: YANGTOOLS-1188
Change-Id: I9fd775be737ef603be7ae2a914dda2c2d87bf8a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use StatementSourceReference in AbstractDeclaredEffectiveStatement 56/93956/4
Robert Varga [Fri, 27 Nov 2020 09:49:40 +0000 (10:49 +0100)]
Do not use StatementSourceReference in AbstractDeclaredEffectiveStatement

We are depending on yang-parser-spi mechanics in what is supposed to be
(relatively) dumb DTOs. Replace this use with a dedicated
SubstatementIndexingException and wrap it in statement supports as
appropriate.

JIRA: YANGTOOLS-1187
Change-Id: I4306bbdfb167b7431bc810a242fa3773f3ec6124
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMigrate coerceStatementArgument() callers 55/93955/1
Robert Varga [Fri, 27 Nov 2020 08:48:36 +0000 (09:48 +0100)]
Migrate coerceStatementArgument() callers

This is a mass migration of callers, deprecating the method
in the process.

Change-Id: I41f44da5c9c460ce971f5c75f4f8b3998a12ecaf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMigrate getStatementArgument() callers 54/93954/1
Robert Varga [Fri, 27 Nov 2020 08:35:38 +0000 (09:35 +0100)]
Migrate getStatementArgument() callers

This is a mass migration of callers, deprecating the method
in the process.

Change-Id: I7e1f736e707971415c8ce5dbdc75ada6b037092d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMigrate coerceRawStatementArgument() callers 53/93953/1
Robert Varga [Fri, 27 Nov 2020 08:28:01 +0000 (09:28 +0100)]
Migrate coerceRawStatementArgument() callers

This is a mass migration of callers, deprecating the method
in the process.

Change-Id: I6a056f0cc9af2e872f85f41fb94c89035fa84ba4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMigrate rawStatementArgument()/getStatementSourceReference() callers 52/93952/1
Robert Varga [Fri, 27 Nov 2020 08:18:13 +0000 (09:18 +0100)]
Migrate rawStatementArgument()/getStatementSourceReference() callers

This is a mass migration of callers, deprecating the two methods
in the process.

Change-Id: Ibda969a84d5a45b624d581e10ed5706b4066625f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMigrate get{PublicDefinition,StatementSource} callers 51/93951/2
Robert Varga [Fri, 27 Nov 2020 04:35:55 +0000 (05:35 +0100)]
Migrate get{PublicDefinition,StatementSource} callers

This is a mass migration of callers, deprecating the two methods
in the process.

Change-Id: Ia7b49a57269eecf5751d669a3fd31dad68b07cb1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSpeed up StmtContextUtils.hasAncestorOfTypeWithChildOfType() 50/93950/2
Robert Varga [Fri, 27 Nov 2020 04:20:46 +0000 (05:20 +0100)]
Speed up StmtContextUtils.hasAncestorOfTypeWithChildOfType()

Representation is an invariant, make sure we acquire it only once
rather than on each check.

Change-Id: I13214cd09d4c812e8c57a28ce47335f77209897d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRefactor AbstractAugmentStatementSupport.copyFromSourceToTarget() 48/93948/2
Robert Varga [Fri, 27 Nov 2020 03:31:37 +0000 (04:31 +0100)]
Refactor AbstractAugmentStatementSupport.copyFromSourceToTarget()

We already have per-version supports, hence can easily specialize
handling of mandatory/when statements. Introduce an abstract
method to facilitate this -- allowing us to remove an explicit
check for yang-version.

Change-Id: Id8cbcd085c851606ac1bfbbb26e771f778edfbdf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFurther StmtContext/CommonStmtCtx merge 47/93947/2
Robert Varga [Fri, 27 Nov 2020 03:11:18 +0000 (04:11 +0100)]
Further StmtContext/CommonStmtCtx merge

Declared/Effective representation can easily be picked up from
the public definition, hence it has a natural place in CommonStmtCtx.
This rehost allows us to fix a few warnings we have been working
around.

Also introduce BoundStmtCtx, which binds the argument, as parsed
by the corresponding support. This allows us to unify argument handling
between StmtContext and EffectiveStmtCtx.Current.

JIRA: YANGTOOLS-1185
Change-Id: Ie2a02ade0616206ff2f677e15bfb8b92878ffbba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoStmtContextUtils.parseNodeIdentifier() is augmentation-agnostic 46/93946/2
Robert Varga [Fri, 27 Nov 2020 03:15:12 +0000 (04:15 +0100)]
StmtContextUtils.parseNodeIdentifier() is augmentation-agnostic

This special-casing code for augmentation history was used when we
did not have BaseQNameStatementSupport.adaptArgumentValue() and used
the parser in context which are not adapted.

Since we have no callers actually hitting this special case, we can
remove it.

Change-Id: Ieaca3ec844fa8e4bc7b28db6732d94d7120e0fdd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove StmtContext.getSchemaPath() 44/93944/5
Robert Varga [Fri, 27 Nov 2020 02:02:28 +0000 (03:02 +0100)]
Remove StmtContext.getSchemaPath()

Access is restricted to EffectiveStmtCtx.Current and this getter
is not really used anymore. Migrate the javadoc to its new place
and remove it from public view.

JIRA: YANGTOOLS-1185
Change-Id: I646e61d70fe4def1af8bb2fdd60d2501a121209c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSplit IfFeatureStatementSupport 45/93945/5
Robert Varga [Fri, 27 Nov 2020 02:16:04 +0000 (03:16 +0100)]
Split IfFeatureStatementSupport

We are using version-dependent argument parsing, which is indicating
this support should have two subclasses, one for each version.

This speeds up processing, as we do not have to lookup the version
and can rely on reactor statement binding to bind the correct support.

Change-Id: I9257760f333af44d063143a95bc4898f63120005
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd EffectiveStmtCtx.root() 43/93943/1
Robert Varga [Fri, 27 Nov 2020 01:29:19 +0000 (02:29 +0100)]
Add EffectiveStmtCtx.root()

Allowing access to CommonStmtCtx view of root is advantageous, as
it allows us to side-step the need to go to StmtContext world.

JIRA: YANGTOOLS-1186
Change-Id: I9ba40ec037f25b07b7f01fd994f60ff78c3c15bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConvert type checking in AbstractTypeStatementSupport 42/93942/4
Robert Varga [Fri, 27 Nov 2020 00:36:52 +0000 (01:36 +0100)]
Convert type checking in AbstractTypeStatementSupport

The effective version  of a statement is dictated by the version we
are bound to -- hence is subject to support subclasses. This removes
a user of EffectiveStmtCtx.yangVersion(), making it less useful.

JIRA: YANGTOOLS-1185
Change-Id: Ia27b6982057e3e683f26ccc60cefb58bbb3eb1d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd CommonStmtCtx 19/93919/6
Robert Varga [Tue, 24 Nov 2020 12:49:56 +0000 (13:49 +0100)]
Add CommonStmtCtx

The idea here is that EffectiveStmtCtx represents an effective view,
whereas StmtContext is an inference view. They share some bits at
the very least.

This patch splits out the common stateless bit, which is not affected
by any sort of interpretation on our part into CommonStmtCtx. This
information is always available and valid.

JIRA: YANGTOOLS-1185
Change-Id: Ia852195811bbd3ec0091fa54488ada230e7f6245
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove use of EffectiveStmtCtx.caerbannog() 41/93941/3
Robert Varga [Thu, 26 Nov 2020 22:59:55 +0000 (23:59 +0100)]
Move use of EffectiveStmtCtx.caerbannog()

Is it turns out a lot of our logic can be migrated to plain
EffectiveStmtCtx.Current access, reducing the number of warnings
and potential exposure of StatementContextBase internals.

JIRA: YANGTOOLS-1186
Change-Id: Ic5dd688c75a0d0e2285b4bef9f1c77f059d09c1c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoNarrow down SuppressFBWarnings in ModelProcessingPhase 29/93929/2
Robert Varga [Wed, 25 Nov 2020 09:14:21 +0000 (10:14 +0100)]
Narrow down SuppressFBWarnings in ModelProcessingPhase

We are suppressing a single null assignment, make sure we minimize
the scope of suppression.

Change-Id: Ie7b62be11964df2553268eb9f49cca1e2c8538b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFixup yang-parser-rfc7950 module 28/93928/2
Robert Varga [Wed, 25 Nov 2020 09:13:15 +0000 (10:13 +0100)]
Fixup yang-parser-rfc7950 module

We are exposing things from reactor, make sure to capture that in
'requires transitive'.

Change-Id: Iaa0412c114996cec55596e672a8d130cef742e73
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoReformulate StatementContextFactory.createEffective() 26/93526/44
Robert Varga [Fri, 30 Oct 2020 21:26:02 +0000 (22:26 +0100)]
Reformulate StatementContextFactory.createEffective()

We need a better handle on what state is being accessed during
createEffective() invocation.

This is achieved by isolating this state into EffectiveStmtCtx,
which gets passed to StatementFactory.createEffective() along
with single-use streams of declared and effective statements.

This interface is then implemented by a proxy in front of a
StatementContextBase, providing effective isolation.

There are a few places which still require direct access to
the underlying StmtContext, but those are limited and subject
to elimination. All of them access backing context through
Current.cearnbannog(), making it easy to spot.

JIRA: YANGTOOLS-1161
Change-Id: I950c466d02c75be1e21a9d0606b990d35e4ca5c2
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSpeed up StmtContextUtils.getModuleQNameByPrefix() 22/93922/1
Robert Varga [Wed, 25 Nov 2020 02:34:26 +0000 (03:34 +0100)]
Speed up StmtContextUtils.getModuleQNameByPrefix()

We are looking up root twice here. Cache the lookup for reuse,
skipping one traversal.

Change-Id: I4ead06fa82b2ef822cbee0a2761bd90674bc1676
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFixup collections return implementations 18/93918/2
Robert Varga [Tue, 24 Nov 2020 12:19:56 +0000 (13:19 +0100)]
Fixup collections return implementations

Adjust nullness annotations to fix Eclipse-reported errors.

Change-Id: I664c651e9bf10fd9d91bae00cc31edf86f9fda0c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSpeed up SchemaTracker.startContainerNode() 10/93910/1
Robert Varga [Sun, 22 Nov 2020 15:21:35 +0000 (16:21 +0100)]
Speed up SchemaTracker.startContainerNode()

Eclipse spotted a potential shortcut in expression, make sure we
take it.

Change-Id: Ief68daa77ac98de3698b9df0627061353055434f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUpdate MutableTreeNode methods 08/93908/1
Robert Varga [Sun, 22 Nov 2020 12:39:36 +0000 (13:39 +0100)]
Update MutableTreeNode methods

Rename addChild() to putChild() and make it return previous child
if this was a replace operation. Also update removeChild() to return
removed child.

JIRA: YANGTOOLS-1182
Change-Id: I0c601f4b6b9d99bcc403b6928f6e8c9bfef36a34
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUpdate StoreTreeNode methods 07/93907/1
Robert Varga [Sun, 22 Nov 2020 10:13:16 +0000 (11:13 +0100)]
Update StoreTreeNode methods

StoreTreeNode.getChild() is forcing users to work on optional,
which is introducing no small amount of complexity. Furthermore it
is not inline with our naming -- that method should be findChild()
at the very least.

JIRA: YANGTOOLS-1181
Change-Id: Ie1c69664c46a9f83154730835d42dcb93778b4a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd MinMaxElementsValidationFailedException 06/93906/2
Robert Varga [Fri, 20 Nov 2020 20:16:16 +0000 (21:16 +0100)]
Add MinMaxElementsValidationFailedException

The refactor we've done makes switch exceptions easy, migrate
MinMaxValidation to a dedicated exception.

JIRA: YANGTOOLS-1177
Change-Id: I005575c93d5683b7fb42428d06f6f052152bc1d0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoReport a dedicated exception on unique failure 05/93905/2
Robert Varga [Fri, 20 Nov 2020 20:05:16 +0000 (21:05 +0100)]
Report a dedicated exception on unique failure

Rather than using plain IllegalArgumentException, report a dedicated
exception derived from SchemaValidationFailedException. Also refactor
UniqueValidation a bit.

Change-Id: If24d97aebab516a461f673c169fa41f9447e0413
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix ListModificationStrategy child handling 04/93904/1
Robert Varga [Fri, 20 Nov 2020 19:55:11 +0000 (20:55 +0100)]
Fix ListModificationStrategy child handling

We have an obviously bad cast here, correct that.

JIRA: YANGTOOLS-1180
Change-Id: I706a5335e899e182e4651e9134f608a6e7094c37
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoHide UniqueValidator methods 93/93893/1
Robert Varga [Fri, 20 Nov 2020 15:54:59 +0000 (16:54 +0100)]
Hide UniqueValidator methods

Our contract is quite crisp, make sure we hide static utility
methods.

JIRA: YANGTOOLS-1177
Change-Id: I9718b7a05cc44906d710a93beaaddd8c12ae93bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd UniqueValidation 84/93884/15
Robert Varga [Wed, 18 Nov 2020 14:41:30 +0000 (15:41 +0100)]
Add UniqueValidation

This is a simplement implementation with a stateless external enforcer,
similar to what MinMaxElementsValidation does. The test suite is split
out of If3b94a085be034de28e341ac900142b021cd2a88 and adapted a bit.

JIRA: YANGTOOLS-1177
Change-Id: I3914497981db0281ab8f32dee12a102ce729022e
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSplit out AbstractValidation 90/93890/3
Robert Varga [Thu, 19 Nov 2020 21:30:20 +0000 (22:30 +0100)]
Split out AbstractValidation

MinMaxElementsValidation performs a useful role as a template for
how we can create simple subtree validations. Split the common bits
into AbstractValidation and elinate code duplication by doing some
trickery.

JIRA: YANGTOOLS-1177
Change-Id: I5adbed16e85f9752a0ce5061b0159c8124583346
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUnify ModificationApplyOperation.toString() 85/93885/2
Robert Varga [Wed, 18 Nov 2020 14:58:36 +0000 (15:58 +0100)]
Unify ModificationApplyOperation.toString()

Not all ModificationApplyOperation subclasses provide useful
information in toString(). Make sure all of them do.

JIRA: YANGTOOLS-1176
Change-Id: Id93f2899dcedd8c289b093c1e126c09108eefb4c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoReduce list/map/entry strategy confusion 83/93883/2
Robert Varga [Wed, 18 Nov 2020 14:24:24 +0000 (15:24 +0100)]
Reduce list/map/entry strategy confusion

Lists with a key are called 'Map' and contain 'MapEntry'
Lists without a key are called a 'List' and do not have an entry
strategy (yet).

Change-Id: I0321eaebf1541a86778c63a2eaa68bdffcd8672a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPropagate @NonNull collection annotations 75/93875/10
Robert Varga [Wed, 18 Nov 2020 11:24:49 +0000 (12:24 +0100)]
Propagate @NonNull collection annotations

We do not allow nulls in our collections. Add the appropriate
annotation to trim down downstream false positives.

Change-Id: Iceaf2bdd6a82b0ad73035ab86d06f283e46c42c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix get{Min,Max}Elements() usage 78/93878/7
Robert Varga [Wed, 18 Nov 2020 12:33:10 +0000 (13:33 +0100)]
Fix get{Min,Max}Elements() usage

These return a nullable, UTs should be using
assertEquals(Object, Object) to compare them.

Change-Id: I6d6aefc94695c5118b4ec4552f64bb45b45dcdc8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClean up argument checking 80/93880/4
Robert Varga [Wed, 18 Nov 2020 12:49:09 +0000 (13:49 +0100)]
Clean up argument checking

We have a few nullness reports, use coerceArgument() when we
are implying a requirement.

Change-Id: I9854f77eeb28945a6cac9fe86695a145eab0687d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove an orElse(null) indirection 79/93879/3
Robert Varga [Wed, 18 Nov 2020 12:46:36 +0000 (13:46 +0100)]
Remove an orElse(null) indirection

We do not need to update foundNode() if we do not find anything,
hence sync on optional directly. Improves interactions and solves
an Eclipse warning.

Change-Id: Ibc553d50d48ccd22480bdc33163364bc8a509c83
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix annotation imports 77/93877/2
Robert Varga [Wed, 18 Nov 2020 12:12:55 +0000 (13:12 +0100)]
Fix annotation imports

We are propagating @NonNull towards our users and are using
@SuppressFBWarnings (which we don't propagate).

JIRA: YANGTOOLS-934
Change-Id: I9e6fc6edb79b7d29f98201b074ca32295b33f646
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCorrect NonNull annotation 74/93874/2
Robert Varga [Wed, 18 Nov 2020 11:24:25 +0000 (12:24 +0100)]
Correct NonNull annotation

We are using the wrong annotation here, fix that.

Change-Id: Ic3c68239f41ada9dfdcc68f9861ce0a142442d89
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove AbstractDeclaredStatement's dependency on StmtContext 50/93550/14
Robert Varga [Tue, 17 Nov 2020 00:31:33 +0000 (01:31 +0100)]
Remove AbstractDeclaredStatement's dependency on StmtContext

As part of the effort to share code, remove StmtContext use in
AbstractDeclaredStatement.

JIRA: YANGTOOLS-1162
Change-Id: I128da9235a5dae956f9cce852679fe515577a703
Signed-off-by: Michal Banik <michal.banik@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConvert yang-data-impl to a JPMS module 48/93848/6
Robert Varga [Mon, 16 Nov 2020 19:49:10 +0000 (20:49 +0100)]
Convert yang-data-impl to a JPMS module

This is a mostly straightforward conversion except we need to move
some files around to allow them to be loaded by external libraries
during UT.

JIRA: YANGTOOLS-1175
Change-Id: Iacecd4157e34c58d35bd2dc495eb178d7e3c86a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFixup rfc8528-data-api module-info 51/93851/2
Robert Varga [Mon, 16 Nov 2020 23:03:20 +0000 (00:03 +0100)]
Fixup rfc8528-data-api module-info

We depend on annotations, make sure to express that.

Change-Id: Ifbd45b538808382228631635d24bd0dac273406c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFixup yang-data-api module-info 50/93850/1
Robert Varga [Mon, 16 Nov 2020 23:01:10 +0000 (00:01 +0100)]
Fixup yang-data-api module-info

We have a couple of dependencies we want to express explicitly,
do that now.

Change-Id: I1e40cab18f0ab10ff08764f6df15dcdf3ec1a23f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDrop dependency on javax.xml.bind 49/93849/2
Robert Varga [Mon, 16 Nov 2020 20:16:24 +0000 (21:16 +0100)]
Drop dependency on javax.xml.bind

All we need is a lenient Base64 decoder. Drop the dependency
on javax.xml.bind and use plain java.base-provided one.

JIRA: YANGTOOLS-1174
Change-Id: If02fce547142f3d5b17d8529716d5b266a50a3a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove OrderedByStatement.Ordering 41/93841/4
Robert Varga [Sun, 15 Nov 2020 23:00:21 +0000 (00:00 +0100)]
Move OrderedByStatement.Ordering

This closed enumeration is a core YANG construct, similar to
Revision, QName, types, etc. which we host in yang-common.

This patch moves it there, adjusting all references.

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