yangtools.git
18 months agoDurationWithTime is a simple record 55/103155/1
Robert Varga [Tue, 8 Nov 2022 17:01:16 +0000 (18:01 +0100)]
DurationWithTime is a simple record

This is a pure value holder, use a record for it.

Change-Id: I3f6743cfbbe74bd7b83acb0b9d8bfb0265f03540
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoUse VarHandles for sum/count tracking 54/103154/1
Robert Varga [Tue, 8 Nov 2022 16:56:53 +0000 (17:56 +0100)]
Use VarHandles for sum/count tracking

Switch from AtomicLongFieldUpdater, which does not give us much, but
makes the class more uniform.

Change-Id: I3ef63910f57a123172906f9814e5aa689c029721
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoUse VarHandles to update shortest/longest duration 53/103153/4
Robert Varga [Tue, 8 Nov 2022 16:36:54 +0000 (17:36 +0100)]
Use VarHandles to update shortest/longest duration

Rather than using ARFU's compareAndSet() and volatile reads, take
advantage of VarHandle's getAcquire() and compareAndExchangeRelease().
This makes things less ordered and more performant in face of races.
Also split out the update logic to aid inlining.

Change-Id: If60016b03c738240d7bdc041c32d5d908b3f002c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoImprove largestQueueSize tracking 50/103150/2
Robert Varga [Tue, 8 Nov 2022 16:02:13 +0000 (17:02 +0100)]
Improve largestQueueSize tracking

VarHandles expose a better API to updating variable than
AtomicIntegerFieldUpdater.

This patch takes advantage of Java 9 memory model to take this variable
out of global volatile happens-before tracking where updates are
concerned. User access still uses a volatile read.

Change-Id: Iba667d501aaebb6cae7e56692bae9e1d840c6807
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoTarget FIXME to next major release 49/103149/2
Robert Varga [Tue, 8 Nov 2022 16:00:19 +0000 (17:00 +0100)]
Target FIXME to next major release

The return value here should have been changed eons ago, target it for
next release.

Change-Id: Ic9e9ec663fefc19513b61e389b8f3948d7aa4fda
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoForeignDataNode is identified by NormalizedNode 00/103100/2
Robert Varga [Fri, 4 Nov 2022 22:15:29 +0000 (23:15 +0100)]
ForeignDataNode is identified by NormalizedNode

Both specializations are using NodeIdentifier, make sure we centralize
that definition.

Change-Id: Ie3eed54476098f583916e4ed37fdfe17ff10eeef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoClean up ExceptionMapper 25/103125/1
Robert Varga [Mon, 7 Nov 2022 13:32:08 +0000 (14:32 +0100)]
Clean up ExceptionMapper

Use Class.isInstance() and Class.cast() instead of unchecked casts. Also
restructure ExecutionException mapping.

Change-Id: I21b61cd99a715746c865d12b378b1874b925519b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoRemove most direct references to builder implementations 43/103043/4
Robert Varga [Thu, 3 Nov 2022 00:21:40 +0000 (01:21 +0100)]
Remove most direct references to builder implementations

We want to hide individual builders, this patch removes most references
outside of core implementation.

Change-Id: I198efa13a0b5700ce066d8d5fbf41a98614f3c40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoReuse the a NodeIdentifier for SchemaContext.NAME 85/103085/1
Robert Varga [Fri, 4 Nov 2022 18:25:20 +0000 (19:25 +0100)]
Reuse the a NodeIdentifier for SchemaContext.NAME

We have an unused constant for this, use it instead of creating one over
and over again.

Change-Id: I5dfc6fddf8eef6c4ed45c1d7926fe09ba4174c35
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoMigrate yang-data-tree-ri to use Builders 45/103045/2
Robert Varga [Thu, 3 Nov 2022 00:59:01 +0000 (01:59 +0100)]
Migrate yang-data-tree-ri to use Builders

Migrate production code to use Builders instead of referencing
individual builders.

Change-Id: I842e8ff71b0dd95fb2fad5f281dfd136d3b85c32
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoUse Builders in yang-data-tree-ri tests 44/103044/4
Robert Varga [Thu, 3 Nov 2022 00:56:38 +0000 (01:56 +0100)]
Use Builders in yang-data-tree-ri tests

We want to hide individual implementations, make sure tests are not
referencing them.

Change-Id: Id6f45b5b2469d949bb4e1aba840a57e2a273483a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoRemove unused logger 03/103003/3
Robert Varga [Tue, 1 Nov 2022 17:35:32 +0000 (18:35 +0100)]
Remove unused logger

DurationStatisticsTracker is not using logging, remove the logger.

Change-Id: I8211d54dbea1dbe9a5c2eeef74ea12a4cc6f067b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoBump versions to 10.0.1-SNAPSHOT 01/103001/1
Robert Varga [Tue, 1 Nov 2022 16:57:25 +0000 (17:57 +0100)]
Bump versions to 10.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: I120b76ff75c67d5ce80709dcf5a2d210633ee29f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoPromote yang-xpath-api to stable 97/102997/3
Robert Varga [Tue, 1 Nov 2022 15:02:42 +0000 (16:02 +0100)]
Promote yang-xpath-api to stable

Most of the constructs here are deemed stable, those that are not can be
evolved as per SemVer.

Change-Id: Ife3030039b1c2dcba1c7261533aca779ca33a811
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoRemove UnresolvedQName.(qualified,unqualified) 00/103000/1
Robert Varga [Tue, 1 Nov 2022 16:31:59 +0000 (17:31 +0100)]
Remove UnresolvedQName.(qualified,unqualified)

These static factory methods have been superseded, remove them.

Change-Id: I2036a619cbc288a38a66390d4983faba060e6732
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoUse java.io.Serial in yang-common 99/102999/1
Robert Varga [Tue, 1 Nov 2022 16:30:50 +0000 (17:30 +0100)]
Use java.io.Serial in yang-common

This is a way of documenting serialization intent, make sure we use it
where appropriate.

Change-Id: I7bcfa898f2f9c21be27dbf99b0d689b19e137871
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoFix maven dependency declarations 98/102998/1
Robert Varga [Tue, 1 Nov 2022 16:20:34 +0000 (17:20 +0100)]
Fix maven dependency declarations

Dependencies should be scope=provided, fix that.

Change-Id: I5c3569991c7a77482714ea1c4fdee022d42ab5cc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoSplit out YangIRSchemaSource 09/102709/5
Robert Varga [Mon, 17 Oct 2022 08:47:37 +0000 (10:47 +0200)]
Split out YangIRSchemaSource

This is a counterpart to YangTextSchemaSource, publish it to
yang-repo-api. This allows is to be consumed without a direct dependency
on YANG parser.

JIRA: YANGTOOLS-1460
Change-Id: Ia7a9d938b8ed94f9b46cd5a22cb86472160dfd98
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoSplit out yang-ir 08/102708/7
Robert Varga [Sun, 16 Oct 2022 23:35:51 +0000 (01:35 +0200)]
Split out yang-ir

We are using a generalized parse tree-based intermediate representation
of YANG files. Publish the object layout from parser so it can be
separately accessed.

JIRA: YANGTOOLS-1460
Change-Id: I965c5cf64b12e849ff4d76db5a8b2c79b1a8856c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoFix anyxml-to-JSON translation duplication error 44/96944/9
Manoj Chokka [Tue, 20 Jul 2021 12:38:00 +0000 (12:38 +0000)]
Fix anyxml-to-JSON translation duplication error

JSONNormalizedNodeStreamWriter generates duplicates when array elements
are not listed consecutively and interleaved with other sibling nodes.
Make sure to check if there is any previously processed sibling node
with the same node name instead of checking just the previous one.

Also, Add a couple of test cases to cover this issue.

JIRA: YANGTOOLS-1302
Change-Id: I4d64c8b8a45009e7667af621c96c34824fb7b48b
Signed-off-by: Manoj Chokka <cmanoj8@gmail.com>
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 months agoPromote plugin-generator-api 96/102996/1
Robert Varga [Tue, 1 Nov 2022 14:47:55 +0000 (15:47 +0100)]
Promote plugin-generator-api

The interfaces here are mature enough to not need special treatment,
drop @Beta annotations.

Change-Id: I829bf26856cd3e299d5a18fe0939ecd68b0fad38
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoPromote yang-data-codec-binfmt to stable status 48/102948/2
Robert Varga [Fri, 28 Oct 2022 21:59:53 +0000 (23:59 +0200)]
Promote yang-data-codec-binfmt to stable status

All interfaces are deemed stable enough, with clear demarcation at major
revisions. Note that the writeout of everything of but latest version is
deprecated for removal.

Change-Id: I6311ce04f1613eaefc60863d93df64bef73efe2a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoEliminate ReactorStmtCtx.boolFlag 45/100945/3
Robert Varga [Sat, 23 Apr 2022 11:44:46 +0000 (13:44 +0200)]
Eliminate ReactorStmtCtx.boolFlag

The existence of this field is a pure memory layout optimization, taking
advantage of alignment shadow provided by isSupportedToBuildEffective.
JDK15+ memory layout logic can take advatage of this hole, rendering
this optimization unnecessary.

Separate the field into its users, naming it appropriatelly.

Change-Id: I807f31268bd384517e1c0db79f24d5fc92f9492c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoRemove an unused constructor 05/102905/1
Robert Varga [Thu, 27 Oct 2022 17:31:48 +0000 (19:31 +0200)]
Remove an unused constructor

Sonar is complaining about this constructor, remove it.

Change-Id: Iab25d1b0b13be32fcee7f298c7dbdfbaf5a87600
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoRemove EffectiveStatement namespaces 00/102900/18
Robert Varga [Wed, 26 Oct 2022 16:59:52 +0000 (18:59 +0200)]
Remove EffectiveStatement namespaces

The idea of complete extensibility with various namespaces is quite
baroque and wasteful. Rather than having a generic get()/getAll()
mechanism, rely on well-defined interface methods that need to be
implemented by the implementations.

This also makes searching much more convenient, without implementations
forcibly requiring Maps or .class addressing, and at the tip of users'
fingertips.

JIRA: YANGTOOLS-1459
Change-Id: Iefaf49a470fa5e93210c7347b3a42f5620c6da36
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoIntroduce RootDeclaredStatement 99/102899/4
Robert Varga [Wed, 26 Oct 2022 16:06:33 +0000 (18:06 +0200)]
Introduce RootDeclaredStatement

We have a number of (mostly-unused) traits, which are implemented by
both ModuleStatement and SubmoduleStatement. Combine these interfaces
into a single interface.

Change-Id: Ide4daa704e0b41cc0916d3acf567302991cf8202
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoRemove ModuleHeaderGroup 98/102898/3
Robert Varga [Wed, 26 Oct 2022 15:51:05 +0000 (17:51 +0200)]
Remove ModuleHeaderGroup

This interface is extended only by ModuleStatement, which implements it
with default methods. Remove ModuleHeaderGroup and implement the methods
directly.

Change-Id: I08e412fd3287ea35e98f7da488fdbe35c730bbb9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoPromote ValueRange 97/102897/3
Robert Varga [Wed, 26 Oct 2022 15:47:11 +0000 (17:47 +0200)]
Promote ValueRange

This is a quite stable API element, remove its @Beta tag.

Change-Id: If7bfbe4488799ef010aadc35b7cc475f16aa4bef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoRemove Rfc6020AbnfRule 96/102896/3
Robert Varga [Wed, 26 Oct 2022 15:44:39 +0000 (17:44 +0200)]
Remove Rfc6020AbnfRule

Remove the annotation and update all its users, so it does not confuse
anyone.

Change-Id: Ief29c36f380a676dd42935eaf6b980eab99924bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoSeal OperationDeclaredStatement 94/102894/3
Robert Varga [Wed, 26 Oct 2022 15:36:47 +0000 (17:36 +0200)]
Seal OperationDeclaredStatement

This is a common super-interface for ActionStatement and RpcStatement,
make sure we seal it to prevent misuse elsewhere.

Change-Id: I52b29e9f5b845ab19d045847183bf374f01f1fa8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoMass-promote DeclaredStatement captures 93/102893/3
Robert Varga [Wed, 26 Oct 2022 15:30:27 +0000 (17:30 +0200)]
Mass-promote DeclaredStatement captures

Declared statements are in a reasoable shape. Add some documentation and
move them out of @Beta.

Change-Id: Ib690d613c28d249c34d29ee064b9d59f6a0b286b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoMass-promote EffectiveStatement captures 91/102891/6
Robert Varga [Wed, 26 Oct 2022 12:34:16 +0000 (14:34 +0200)]
Mass-promote EffectiveStatement captures

The hierarchy and capabilities of EffectiveStatements are well-defined
and quite safe for use. Drop their @Beta annotations and add javadocs
where those were missing.

Change-Id: I7b0469aca9d527a81d59cad513707c424c978294
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoDeprecate Rfc6020AbnfRule 95/102895/2
Robert Varga [Wed, 26 Oct 2022 15:38:24 +0000 (17:38 +0200)]
Deprecate Rfc6020AbnfRule

This annotation is used for very light documentation purposes only.
It also does not have an RFC7950 counterpart nor can it express the
various definitions in YANG extensions. Deprecate it for removal.

Change-Id: I13eff70e8cf8dc20bfdaf42969ab92b608bc1dff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoDocument Key(Effective)Statement's argument 92/102892/2
Robert Varga [Wed, 26 Oct 2022 15:04:46 +0000 (17:04 +0200)]
Document Key(Effective)Statement's argument

Iteration order of the returned set has additional requirements, make
sure we document them.

Change-Id: I72ed3c8e45e7149187a4c295ab3e3d6526fbb368
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoDocument UniqueStatement 90/102890/2
Robert Varga [Wed, 26 Oct 2022 12:33:51 +0000 (14:33 +0200)]
Document UniqueStatement

We do not have any javadocs, adds some basics.

Change-Id: Ic449d949b78e7313104fa32f0ad99c09037bed4a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoPromote ArgumentDefinition 89/102889/2
Robert Varga [Wed, 26 Oct 2022 12:19:29 +0000 (14:19 +0200)]
Promote ArgumentDefinition

This construct is suitably stable for normal use, remove @Beta
declaration.

Change-Id: Id865e1a6ffafdd82479e5fb9cf811e443c5f3552
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoMass-promote yang.model.api constructs 86/102886/2
Robert Varga [Wed, 26 Oct 2022 11:51:32 +0000 (13:51 +0200)]
Mass-promote yang.model.api constructs

The following constructs are deemed stable enough for normal use:
- ActionDefinition
- ActionNodeContainer
- AddedByUsesAware (although it is deprecated)
- AnydataSchemaNode
- ContainerLike
- EffectiveStatementEquivalent
- InputSchemaNode
- OutputSchemaNode
- OperationDefinition
- PathExpression

Change-Id: I0bd793add470adf1d90d4e098e592efc921a76de
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoPromote DataNodeContainer.findDataTreeChild() 85/102885/2
Robert Varga [Wed, 26 Oct 2022 11:45:07 +0000 (13:45 +0200)]
Promote DataNodeContainer.findDataTreeChild()

Do not use Optional internally, reduce casts and promote these methods
to stable API.

Change-Id: I66b36a5e138f049a4431141a70147bf01cb39f02
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoOptimize DataNodeContainer.findDataChildByName() 84/102884/2
Robert Varga [Wed, 26 Oct 2022 11:39:53 +0000 (13:39 +0200)]
Optimize DataNodeContainer.findDataChildByName()

Ditch the internal use of Optional, which allows us to use simpler
traversal logic.

Change-Id: Idd30830b434e40d3d15d00bdda8efcab253b4590
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoMass-promote concepts 83/102883/2
Robert Varga [Wed, 26 Oct 2022 11:13:17 +0000 (13:13 +0200)]
Mass-promote concepts

The following concepts are deemed stable enough to lose @Beta
annotation:
- PrettyTree
- ExtensibleObject
- ObjectExtension
- ObjectExtensions
- WritableObject
- WritableObjects
- WritableIdentifier

Change-Id: Iff82ecbae7456edb8e74d2f9e0cefe57564e82b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoPromote yang-model-export classes to stable 82/102882/2
Robert Varga [Wed, 26 Oct 2022 10:02:40 +0000 (12:02 +0200)]
Promote yang-model-export classes to stable

Drop @Beta annotations, as the contracts here are sufficiently stable.

Change-Id: Id72dd37da28daf6c53d7ad7037dc2ed76c547a95
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoUse a record for OpenElement 81/102881/2
Robert Varga [Wed, 26 Oct 2022 09:59:31 +0000 (11:59 +0200)]
Use a record for OpenElement

This is a simple holder of two references, model it as such.

Change-Id: Iad079aa78bcb87a738319312415becf1e5034fc7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoUse Optional.ifPresent() 80/102880/1
Robert Varga [Wed, 26 Oct 2022 09:49:32 +0000 (11:49 +0200)]
Use Optional.ifPresent()

Use a simple lambda for appending the optional prefix.

Change-Id: I17a79f73dcb10d2b6826b5fb9c0a368e723a7ccd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoUse local variable type inference in yang-model-export 79/102879/1
Robert Varga [Wed, 26 Oct 2022 09:43:44 +0000 (11:43 +0200)]
Use local variable type inference in yang-model-export

This cleans up some of the code verbosity.

Change-Id: I6d026214ad3229852984e06deb08b5a2148015f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoUse instanceof pattern match in yang-model-export 78/102878/1
Robert Varga [Wed, 26 Oct 2022 09:48:11 +0000 (11:48 +0200)]
Use instanceof pattern match in yang-model-export

This allows for more exhaustive checks and makes code a bit more clear.

Change-Id: I50c8ab52f39b398890621cdd474a0f85aef7f181
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoRemove deprecated YingExportUtils methods 77/102877/1
Robert Varga [Wed, 26 Oct 2022 09:50:40 +0000 (11:50 +0200)]
Remove deprecated YingExportUtils methods

The callers can make the switch themselves, remove migration methods.

Change-Id: Iad94c417d78debedc3571e44f10f2956e37fb892
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoModernize AbstractCodecFactory a bit 72/102872/2
Robert Varga [Tue, 25 Oct 2022 13:28:30 +0000 (15:28 +0200)]
Modernize AbstractCodecFactory a bit

Use local variable type inference and instanceof patterns.

Change-Id: I9ba940e18a4f1ead42ffe32b7a37bed1f922c6ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoModernize IdentityCodecUtil a bit 71/102871/1
Robert Varga [Tue, 25 Oct 2022 13:20:12 +0000 (15:20 +0200)]
Modernize IdentityCodecUtil a bit

Use local variable type inference and Optional.orElseThrow().

Change-Id: I4de98926da01f6d4f1209b676c2315501e8da5b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoModernize ParserStreamUtils a bit 70/102870/1
Robert Varga [Tue, 25 Oct 2022 13:14:02 +0000 (15:14 +0200)]
Modernize ParserStreamUtils a bit

Use variable type inference and instanceof patterns.

Change-Id: I771e92538f7ab87167992a1952ef8de61e88505f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoUse instanceof patterns in NormalizedNodeStreamWriterStack 69/102869/1
Robert Varga [Tue, 25 Oct 2022 13:10:25 +0000 (15:10 +0200)]
Use instanceof patterns in NormalizedNodeStreamWriterStack

We have a few places where we can apply these shortcuts, improving
safety and expressiveness.

Change-Id: I80bfbab9adb21ae2f0727d9e52135a103d0ecba8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoSeal XMLStreamNormalizedNodeStreamWriter 68/102868/1
Robert Varga [Tue, 25 Oct 2022 12:40:18 +0000 (14:40 +0200)]
Seal XMLStreamNormalizedNodeStreamWriter

We have only two specializations of this construct, make sure we do not
allow it to be otherwise subclassed.

Change-Id: Ibfae6c844aa4626bba7004a257a04383798d272c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoBump odlparent to 12.0.0 62/102862/1
Robert Varga [Mon, 24 Oct 2022 18:45:22 +0000 (20:45 +0200)]
Bump odlparent to 12.0.0

Pick up the next version of odlparent.

Change-Id: I54b8c36865438488662cdfa24ebea118fa19ba60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoUse instanceof patterns in XmlParserStream 31/102831/2
Robert Varga [Fri, 21 Oct 2022 14:08:51 +0000 (16:08 +0200)]
Use instanceof patterns in XmlParserStream

We can ditch a few explicit casts if we use instanceof patterns, let's
do that.

Change-Id: I820e2469948d88e3ecfc06b3a2e2dbadf6658df4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoMove AntlrSupport 01/102701/3
Robert Varga [Sun, 16 Oct 2022 23:07:12 +0000 (01:07 +0200)]
Move AntlrSupport

The binding works in exact opposite way: the antlr package knows how to
represent IR things.

Change-Id: I4d20dcb206750a6a2185c22a8620fca95d12282f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoRework IR API instantiation 99/102699/2
Robert Varga [Sun, 16 Oct 2022 21:39:54 +0000 (23:39 +0200)]
Rework IR API instantiation

Prepare for splitting out of IR{Argument,Keyword,Statement} interfaces,
implementation and users:
- hide pure implementation details
- expose factory methods

Change-Id: I2ec099ddcdb617fa0ac10b06515b65c4ba9602ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoMove IRSchemaSource 98/102698/2
Robert Varga [Sun, 16 Oct 2022 20:31:09 +0000 (22:31 +0200)]
Move IRSchemaSource

IRSchemaSource is a yang-repo-api contract, it should live in
rfc7950.repo until we find it a better place. This allows is to remove
the export of yang.parser.rfc7950.ir.

Change-Id: I78f71ae6491d0e551f957819fb77f30c8910c00e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoRemove yang-maven-plugin interfaces 54/93554/24
Robert Varga [Mon, 2 Nov 2020 16:09:48 +0000 (17:09 +0100)]
Remove yang-maven-plugin interfaces

yang2sources.spi package has been deprecated for a long time, remove
it. This will allow us to properly control file lifecycle and perform
correct incremental builds.

integration tests were updated to match actual state.

JIRA: YANGTOOLS-747
Change-Id: I5e3acf0df97a33e7507841a549fa7109b48c16c3
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
19 months agoSeal SchemaSourceRepresentation hierarchy 90/102690/2
Robert Varga [Fri, 14 Oct 2022 12:00:25 +0000 (14:00 +0200)]
Seal SchemaSourceRepresentation hierarchy

There are really only two basic SchemaSourceRepresentations: either YIN
or YANG. Make sure we express that through sealing interfaces. This
exposes the fact IRSchemaSource is a YangSchemaSourceRepresentation.

Change-Id: Ic0e073deefeef541ff4461c17e1dacffe4324da4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoClean up antlr/parser utilities 80/102680/1
Robert Varga [Thu, 13 Oct 2022 22:21:47 +0000 (00:21 +0200)]
Clean up antlr/parser utilities

We can seal the token hierarchy, let's do that to improve clarity as to
what is going on.

Change-Id: I982831143d462e53def2a7ea9283d7509c1fdaff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoUse switch expressions in AntlrSupport 74/102674/1
Robert Varga [Thu, 13 Oct 2022 17:03:48 +0000 (19:03 +0200)]
Use switch expressions in AntlrSupport

This is a mostly-automated conversion, except for a few comments.

Change-Id: I027159cd0ee135fd8ea2ef1cd98747b298dac239
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoAdd AbstractIRObject equality contract 73/102673/2
Robert Varga [Thu, 13 Oct 2022 16:40:40 +0000 (18:40 +0200)]
Add AbstractIRObject equality contract

Make sure the objects we are giving out implement proper equality. Also
use JDK17 features to seal the class hierarchy.

Change-Id: Iff7f3fa1f071f44e41eb322e8adc070030cdbd30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoModernize YangDataExtensionTest 95/102595/3
Robert Varga [Tue, 11 Oct 2022 12:56:36 +0000 (14:56 +0200)]
Modernize YangDataExtensionTest

Use local variable type inference to reduce verbosity a bit.

Change-Id: I3006823047e8f8643c781ab0b086ff014aab1bc3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoFix yang-data extension definition 02/101302/10
Peter Suna [Thu, 26 May 2022 09:58:49 +0000 (11:58 +0200)]
Fix yang-data extension definition

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

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

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

JIRA: YANGTOOLS-1443
Change-Id: I3f78f71ea2980bf84f409d1ec89979e9e7b200ae
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoRemove SchemaAwareBuilders 56/102556/6
Robert Varga [Tue, 4 Oct 2022 14:12:14 +0000 (16:12 +0200)]
Remove SchemaAwareBuilders

This reverts commit ed354e4ac28c35091d7bce0bd74919118916d999, removing
SchemaAwareBuilders again.

JIRA: YANGTOOLS-1249
Change-Id: Ia40bf36e7edd569de22e32a844ab40ab15fc46ae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoTighten AbstractImmutableDataContainerNodeBuilder constructors 57/102557/1
Robert Varga [Tue, 4 Oct 2022 15:32:13 +0000 (17:32 +0200)]
Tighten AbstractImmutableDataContainerNodeBuilder constructors

The class is not visible outside the package, there is no point in
protected visibility.

Change-Id: I8944000865766720d03c04840803752269e878d1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoReduce code duplication in InferredStatementContext 55/102555/5
Robert Varga [Tue, 4 Oct 2022 13:15:11 +0000 (15:15 +0200)]
Reduce code duplication in InferredStatementContext

We are treating declared/effective copies the same way -- isolate
duplicated code into utility methods.

Change-Id: I1faa7348fb7185a60abeec75c041aa0466998b00
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoImprove StatementContextBase.stream{Declared,Effective} 54/102554/2
Robert Varga [Tue, 4 Oct 2022 13:08:07 +0000 (15:08 +0200)]
Improve StatementContextBase.stream{Declared,Effective}

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

Change-Id: I7b4ab5c1032d719520bcdf046045bd6638aea13a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoSeal PathArgumentList 38/102038/4
Robert Varga [Wed, 10 Aug 2022 14:51:03 +0000 (16:51 +0200)]
Seal PathArgumentList

We have only two possible subclasses, make sure we use a sealed class
for that.

Change-Id: Ibb0297a660c0d61e766ee0fd8303500c44efd1dc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoEnforce range constraints in DecimalStringCodec 56/102056/8
OleksandrZharov [Thu, 11 Aug 2022 10:16:49 +0000 (12:16 +0200)]
Enforce range constraints in DecimalStringCodec

Added check which will report YangInvalidValueException if the parsed
value doesn't match range constraints specified in DecimalTypeDefinition.
Added explicit test for this change.

JIRA: YANGTOOLS-1442
Change-Id: I7a00fb540ae64e8f5bdde58aa7297e0e5f91d780
Signed-off-by: OleksandrZharov <Oleksandr.Zharov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoFix DataTreeCandidateNodes handling of deleted nodes 36/102536/5
Robert Varga [Mon, 3 Oct 2022 08:42:11 +0000 (10:42 +0200)]
Fix DataTreeCandidateNodes handling of deleted nodes

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

JIRA: YANGTOOLS-1455
Change-Id: I6a89f8e59a7f8d8b36c5c5d2990290f66f79f529
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoClean up TerminalDataTreeCandidateNode 34/102534/3
Robert Varga [Mon, 3 Oct 2022 08:36:24 +0000 (10:36 +0200)]
Clean up TerminalDataTreeCandidateNode

This class is supposed to be final and we should be mapping Optionals
instead of explicit isPreset/get calls.

Change-Id: Id30df72c8afe95c64dafe17a34f06eef01569535
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoCleanup DataTreeCandidatesAggregateTest 37/102537/2
Robert Varga [Mon, 3 Oct 2022 09:30:03 +0000 (11:30 +0200)]
Cleanup DataTreeCandidatesAggregateTest

Use static import for ModificationType and prefer
Optional.orElseThrow().

Change-Id: Ie977782ccad84ebaf2b6e3cc9f3667f3e9b151dc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoImprove StmtContext.copyAsChild() type safety 16/102516/1
Robert Varga [Fri, 30 Sep 2022 12:58:02 +0000 (14:58 +0200)]
Improve StmtContext.copyAsChild() type safety

We should not be losing A/D/E type capture, but rather propagate it.

Change-Id: I6254a4f0ef0fea5b79815e99d1e6b03d33f679e4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
19 months agoUse enhanced for loop 15/102515/1
Robert Varga [Fri, 30 Sep 2022 12:56:54 +0000 (14:56 +0200)]
Use enhanced for loop

We are using simple iteration, hence we can hide the original iterator.

Change-Id: I4eb7300023581132a424d7bca99ac6541085011e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoAdd FIXMEs to IdentifierNamespace 72/102172/2
Robert Varga [Fri, 19 Aug 2022 21:25:15 +0000 (23:25 +0200)]
Add FIXMEs to IdentifierNamespace

This namespace is using Class-based addressing, which is ugly from end
user as well as expresiveness perspective.

Change-Id: I6d5c9b09845b144bf138c248580cd0bdef6ee08e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoMake ParserNamespace final 71/102171/2
Robert Varga [Fri, 19 Aug 2022 20:44:32 +0000 (22:44 +0200)]
Make ParserNamespace final

SchemaTreeNamespace does not bring much to the picture, remove it
and make ParserNamespace a final class.

JIRA: YANGTOOLS-1453
Change-Id: I7dbffb9f3ab109a418fcafb59a464aab156c710b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoMove SchemaTreeNamespace.findNode() 70/102170/3
Robert Varga [Fri, 19 Aug 2022 13:15:12 +0000 (15:15 +0200)]
Move SchemaTreeNamespace.findNode()

SchemaTreeNamespace as a separate class may be going away, let's
migrate its utility method to a different place.

JIRA: YANGTOOLS-1453
Change-Id: Iabee4a009591af75aa46560d09e15b1043abeabd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove Source{ParserNamespaces,NamespaceBehaviours} 57/102157/2
Robert Varga [Thu, 18 Aug 2022 21:45:48 +0000 (23:45 +0200)]
Remove Source{ParserNamespaces,NamespaceBehaviours}

There is no point in keeping two classes, as the namespaces are wild and
dis-organized anyway.

JIRA: YANGTOOLS-1453
Change-Id: I359af4e37334354354e1f59cccda5b56ff1ab9a9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoImprove ParserNamespace type safety 56/102156/2
Robert Varga [Thu, 18 Aug 2022 20:56:19 +0000 (22:56 +0200)]
Improve ParserNamespace type safety

Specify concrete argument types to prevent any shenaningans.

JIRA: YANGTOOLS-1453
Change-Id: I1d82058e92f2afe0de740df1093ea43f12cb7244
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove StatementNamespace 53/102153/3
Robert Varga [Thu, 18 Aug 2022 16:05:03 +0000 (18:05 +0200)]
Remove StatementNamespace

This is a pure type capture of keys and values, let's remove the
indirection. This also improves type safety of users, as we can cleanly
express StmtContext type (based on the ParserNamespace type).

JIRA: YANGTOOLS-1453
Change-Id: Icc626957b6b3b94c9cdd89a518be6037f4fdaaac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove ImportedNamespaceContext 52/102152/2
Robert Varga [Thu, 18 Aug 2022 15:41:25 +0000 (17:41 +0200)]
Remove ImportedNamespaceContext

This indirection is not actually useful, as it only captures generics.
Remove it to simplify our class hierarchy.

JIRA: YANGTOOLS-1453
Change-Id: I2eb4f247bb61f3547fc3a65e8a92ed7d44671e88
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoEliminate StatementNamespace.TreeScoped 51/102151/2
Robert Varga [Thu, 18 Aug 2022 15:28:57 +0000 (17:28 +0200)]
Eliminate StatementNamespace.TreeScoped

This subclass is not really useful, as it just mirrors
NamespaceBehaviour.treeScoped(). Remove it to flatten the type hierarchy
a bit.

JIRA: YANGTOOLS-1453
Change-Id: I651c8682c1198c766fc6ad512bf444e9df77b365
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove ParserNamespace type captures 49/102149/6
Robert Varga [Thu, 18 Aug 2022 11:49:50 +0000 (13:49 +0200)]
Remove ParserNamespace type captures

We are overly-generifying the situation around namespaces. Just pass
objects down and stop worrying.

JIRA: YANGTOOLS-1453
Change-Id: Ieb937fcc68ee65d396f5faaa6b0f1f1a200499e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoMake ParserNamespace an identifier 44/102144/12
Robert Varga [Thu, 18 Aug 2022 08:25:19 +0000 (10:25 +0200)]
Make ParserNamespace an identifier

We are using Class objects to identify namespaces. This patch makes
ParserNamespace an Identifier and uses it instead of Class to refer
to namespaces.

This has the side-effect of removing a ton of classes and turning them
into singleton objects instead.

JIRA: YANGTOOLS-1453
Change-ID: I796ecf22c2c22b512ef0db4d0d4a06b8ea69c23f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoTurn ParserNamespace into an abstract class 40/102140/18
Robert Varga [Wed, 17 Aug 2022 17:28:40 +0000 (19:28 +0200)]
Turn ParserNamespace into an abstract class

This is an effort to stop addressing namespaces through .class objects,
but rather through objects. As a first step switch to the hierarchy to
be based on an abstract class and make concrete namespaces final.

JIRA: YANGTOOLS-1453
Change-Id: Ib09406f8c4d667d45676c6cd3f01cd64434f1c0c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoResolve SchemaTreeNamespace cognitive dissonance 46/102146/3
Robert Varga [Thu, 18 Aug 2022 07:44:24 +0000 (09:44 +0200)]
Resolve SchemaTreeNamespace cognitive dissonance

SchemaTreeNamespaces currently combines a ParserNamespace and a
NamespaceBehaviour. Split the two concerns so we can evolve them
further.

JIRA: YANGTOOLS-1453
Change-Id: I1624ef8795f236b2e440528bf43f10d9df2aface
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoResolve PrefixToModule cognitive dissonance 43/102143/6
Robert Varga [Wed, 17 Aug 2022 18:38:36 +0000 (20:38 +0200)]
Resolve PrefixToModule cognitive dissonance

This class serves two purposes: a namespace for reactor interactions
and XML source lookup. The second purpose is really a resolver
interface, split it out and clean up api/impl mess.

JIRA: YANGTOOLS-1452
Change-Id: I0fdfaee784a9c95bad0a64f746f0a1fe6412646e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove PrefixToModule.DEFAULT_PREFIX 42/102142/1
Robert Varga [Wed, 17 Aug 2022 18:35:32 +0000 (20:35 +0200)]
Remove PrefixToModule.DEFAULT_PREFIX

Remove this constant, as it's just getting in the way.

Change-Id: Ib19ededfbbcb9df310775a7d34d7090225cc86ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoDeprecate PrefixToModule.DEFAULT_PREFIX 41/102141/1
Robert Varga [Wed, 17 Aug 2022 18:34:25 +0000 (20:34 +0200)]
Deprecate PrefixToModule.DEFAULT_PREFIX

There are no users, we are removing this constant. If it re-emerges, it
will be its proper semantic point with proper binding towards
XMLContants.

Change-Id: I9b36846dfbaa01084bb053f0f4f3625313671e8e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoCleanup MutableOffsetMap a bit 37/102137/1
Robert Varga [Wed, 17 Aug 2022 15:41:57 +0000 (17:41 +0200)]
Cleanup MutableOffsetMap a bit

Use instanceof patterns and guarantee @NonNull clone().

Change-Id: I40efddbf0d248427cd9d01cd13ef26db94b0377a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoAdd StmtContextUtils.getModuleQName() 32/102132/1
Robert Varga [Wed, 17 Aug 2022 13:39:36 +0000 (15:39 +0200)]
Add StmtContextUtils.getModuleQName()

We can make things safer by requiring a RootStmtContext, which in turn
allows us to take a slight shortcut.

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

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

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

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

JIRA: YANGTOOLS-1436
Change-Id: I71eb1122bf7c3820043a3197249a3b2fba6e9e8c
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove BelongsToModuleContext 31/102131/1
Robert Varga [Wed, 17 Aug 2022 11:32:50 +0000 (13:32 +0200)]
Remove BelongsToModuleContext

This namespace is not really useful, as it can contain really just a
single mapping (due to belongs-to cardinality). Also the key is never
used, which means BelongsToPrefixToModuleCtx can serve exactly the same
needs.

Change-Id: I08d92148f330fc0da8ff99443bdce270def3924c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoUse List for importedNamespace 30/102130/1
Robert Varga [Wed, 17 Aug 2022 11:15:21 +0000 (13:15 +0200)]
Use List for importedNamespace

Collection is too vague and we always implement it with a List, make
sure that is reflected in the declaration.

Change-Id: I1323e9649427ca31d9884f3a8d9c2fd221df933a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove old YangInstanceIdentifier serialization 23/102123/4
Robert Varga [Wed, 17 Aug 2022 08:13:23 +0000 (10:13 +0200)]
Remove old YangInstanceIdentifier serialization

YangInstanceIdentifier is written out through YIDv1 since version 3.0.0,
there is no point in supporting direct serialization methods anymore.
This has a nice effect of ditching reflection.

Change-Id: I50ad185df83b88495cb1fc1024170dcb4cd41ade
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoRemove NIPv1 22/102122/3
Robert Varga [Wed, 17 Aug 2022 08:07:16 +0000 (10:07 +0200)]
Remove NIPv1

This serialization proxy has been deprecated since 4.0.0, remove it as
we should not be encountering it anymore.

Change-Id: I040e4c347662f7ca684ab910db3f6a800e996ccf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoSprinkle @Serial annotations on yang-data-api 21/102121/3
Robert Varga [Wed, 17 Aug 2022 08:01:23 +0000 (10:01 +0200)]
Sprinkle @Serial annotations on yang-data-api

We are about to move forward on serialization, make sure the methods are
properly annotated.

Change-Id: I3613ab4436d4503a0117983d5e4cd3254e48b95d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoSeal SingletonSet 44/102044/19
Robert Varga [Wed, 10 Aug 2022 21:25:14 +0000 (23:25 +0200)]
Seal SingletonSet

We cannot have an anonymous subclass and also seal it. Since we have
solved the writeout path, we can just rely on SSv1 to do the most of the
lifting and break the format.

Change-Id: I34177672db7a2f1d91731978205d20e76353aaa7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoUse SSv1 during writeout 19/102119/2
Robert Varga [Wed, 17 Aug 2022 07:45:08 +0000 (09:45 +0200)]
Use SSv1 during writeout

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

Change-Id: I7b602f166bccc418ea27af0b887f5868fadbf9e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
21 months agoAdd SSv1 18/102118/2
Robert Varga [Wed, 17 Aug 2022 07:42:35 +0000 (09:42 +0200)]
Add SSv1

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

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