yangtools.git
7 months agoRemove EffectiveAugmentationSchema 56/108256/2
Robert Varga [Thu, 5 Oct 2023 15:04:54 +0000 (17:04 +0200)]
Remove EffectiveAugmentationSchema

This class is not needed anywhere and has been deprecated for removal.
Remove it in this major iteration.

Change-Id: Ibad4f6e66b559285e5fda61281e421c12da23838
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDrop QNameModuleAware from AugmentEffectiveStatementImpl 18/107918/3
Robert Varga [Tue, 19 Sep 2023 16:41:06 +0000 (18:41 +0200)]
Drop QNameModuleAware from AugmentEffectiveStatementImpl

This interface is not specified and hence should not be used.

JIRA: YANGTOOLS-1409
Change-Id: I5d3d6dc34d85d360e92c05f083f10b475c732b0a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoReduce use of yang.model.api 53/106953/5
Robert Varga [Fri, 21 Jul 2023 09:07:29 +0000 (11:07 +0200)]
Reduce use of yang.model.api

AbstractModuleStringInstanceIdentifierCodec really needs only
QNameModule, update its contract to not rely on yang.model.api.Module.

JIRA: YANGTOOLS-1524
Change-Id: I2648be150328a945a3f53c85820d91c9a112674e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove EvenMoreObjects 55/108255/1
Robert Varga [Thu, 5 Oct 2023 15:02:40 +0000 (17:02 +0200)]
Remove EvenMoreObjects

This class is completely unused and deprecated for removal. Remove it as
part of this major version bump.

Change-Id: Ic1daa590d19595d78f07884c5f5af4d2b992e82e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove getValue() methods from model.api.stmt interfaces 54/108254/1
Robert Varga [Thu, 5 Oct 2023 15:01:08 +0000 (17:01 +0200)]
Remove getValue() methods from model.api.stmt interfaces

These methods have been deprecated for removal, remove them as part of
the next major release.

Change-Id: Id982b9a9135eca421c991d3943f3fdfe93f3ed0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove obsolete DataTreeCandidateNode methods 25/106225/4
Robert Varga [Mon, 29 May 2023 08:46:28 +0000 (10:46 +0200)]
Remove obsolete DataTreeCandidateNode methods

These methods have been deprecated for removal, remove them now.

Change-Id: I7e27d15fa2ab9a239fd2d4c9de0f81251a11eac0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not trim XML element text 45/106945/8
Robert Varga [Thu, 20 Jul 2023 23:51:30 +0000 (01:51 +0200)]
Do not trim XML element text

Historically we have been trimming the content of XML elements, which
means we accepted leading/trailing whitespace for uint8 and similar
encodings.

This is not correct and this patch eliminates all trimming.

JIRA: YANGTOOLS-1523
Change-Id: I7060f8f2bf3374b4ca49629b6c4cdddb85660567
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove AbstractStringIdentityrefCodec and its subclasses 35/108035/4
Robert Varga [Thu, 5 Oct 2023 13:03:43 +0000 (15:03 +0200)]
Remove AbstractStringIdentityrefCodec and its subclasses

These classes are not used anywhere, remove them.

Change-Id: I56f257874c422ac33e0f37608e694c90fb7f4729
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoImprove AbstractNamespaceCodec 34/108034/3
Robert Varga [Thu, 28 Sep 2023 21:46:00 +0000 (23:46 +0200)]
Improve AbstractNamespaceCodec

Improve nullness guarantees in createQName().

Change-Id: Icdb58b2ede7a5e2b8f380614719f3a1842255e53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoPromote AbstractStringInstanceIdentifierCodec 33/108033/2
Robert Varga [Thu, 28 Sep 2023 21:40:57 +0000 (23:40 +0200)]
Promote AbstractStringInstanceIdentifierCodec

Integrate AbstractModuleStringInstanceIdentifierCodec, which is the only
subclass in active use. Drop @Beta moniker.

Change-Id: I5fe285feefd7db75fa73d8903f9d866390f9365f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoForce subclasses to implement deserializeKeyValue() 32/108032/4
Robert Varga [Thu, 28 Sep 2023 20:50:38 +0000 (22:50 +0200)]
Force subclasses to implement deserializeKeyValue()

Just passing values through is not appropriate -- everyone needs to
explicitly deal with values.

Change-Id: If019d9f1194dae0faa624d2ec08e09b043a4183d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoSwitch to using ModuleEffectiveStatement in codecs 31/108031/4
Robert Varga [Thu, 28 Sep 2023 20:48:27 +0000 (22:48 +0200)]
Switch to using ModuleEffectiveStatement in codecs

Rather than using Module, use ModuleEffectiveStatement, which provides
very similar facilities.

Change-Id: I3961e6dc17c236b71ebf555519ea06d3cbdc218b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoBump versions to 12.0.0-SNAPSHOT 50/108250/2
Robert Varga [Thu, 5 Oct 2023 12:49:37 +0000 (14:49 +0200)]
Bump versions to 12.0.0-SNAPSHOT

This starts the next development iteration.

Change-Id: Ie1a2c561e3fcc17a487cdb89e9bbbed83fca03d7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not use Optional in returns 04/107704/11
Robert Varga [Tue, 5 Sep 2023 00:59:37 +0000 (02:59 +0200)]
Do not use Optional in returns

Optionals are providing type-safety, but we can achieve the same thing
with @Nullable TreeNode. Update call convention to reflect that.

JIRA: YANGTOOLS-1538
Change-Id: I67cbf46d2683c454f5aaece40041bef02d5dab0b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRefactor ModificationApplyOperation 93/107693/18
Robert Varga [Mon, 4 Sep 2023 18:50:25 +0000 (20:50 +0200)]
Refactor ModificationApplyOperation

Use currentMeta as a @Nullable TreeNode, replacing checks as
appropriate.

JIRA: YANGTOOLS-1538
Change-Id: I7dfeea43515fe0dd3099ed2dd48086fd8f297ea8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not store Optional in ModifiedNode 92/107692/8
Robert Varga [Mon, 4 Sep 2023 18:15:35 +0000 (20:15 +0200)]
Do not store Optional in ModifiedNode

Storing an Optional is a bit superfluous and an anti-pattern. Use a
@Nullable type instead. Also migrate users which can easily use a
nullable instead of Optional.

JIRA: YANGTOOLS-1538
Change-Id: I70bdea652ee0186aae6109db1ae756780eaa54b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoBump versions to 6.0.4-SNAPSHOT 64/108164/1
Robert Varga [Mon, 2 Oct 2023 16:59:22 +0000 (18:59 +0200)]
Bump versions to 6.0.4-SNAPSHOT

This starts the next development iteration.

Change-Id: I72d3516453d2a222698d4c7a3243543c1ae65f3f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRelease yangtools v11.0.3
jenkins-releng [Mon, 2 Oct 2023 15:31:55 +0000 (15:31 +0000)]
Release yangtools

7 months agoImprove InMemoryDataTreeModification state management 98/107698/8
Robert Varga [Mon, 4 Sep 2023 21:23:11 +0000 (23:23 +0200)]
Improve InMemoryDataTreeModification state management

We have an int here, which allows us to express multiple states. Improve
state tracking defensiveness to differentiate between "open" state and
two states ready() goes through.

This means we can detect when ready() ends up not completing
successfully as observed by other validation code.

JIRA: YANGTOOLS-1539
Change-Id: I10a233adf53029d14ba37751cc3cc9f38fc2a85d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoBump odlparent to 13.0.5 65/108065/5
Robert Varga [Fri, 29 Sep 2023 16:37:30 +0000 (18:37 +0200)]
Bump odlparent to 13.0.5

Adopt latest fixes from upstream.

Change-Id: Ie1cd315eb8002e560e7c978d7c63c1739a7fe3fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoConvert parser extensions into JPMS modules 94/108094/3
Robert Varga [Sun, 1 Oct 2023 16:04:11 +0000 (18:04 +0200)]
Convert parser extensions into JPMS modules

These are some of of the final pieces of conversion, perform the trivial
conversion.

Change-Id: I9e2f08b428948faec8949fae175d0f04ee7c9484
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMake model prefix handling optional 80/108080/3
Robert Varga [Sat, 30 Sep 2023 00:22:32 +0000 (02:22 +0200)]
Make model prefix handling optional

Taking model-based prefixes into account is bound to change our output,
making the encoding a tad more dense. Make the feature selectable by
users as a first step, with an eye towards making it the default.

JIRA: YANGTOOLS-1544
Change-Id: Icedf67b408182e57a99d5d1f52f728c3f64c8657
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up NamespacePrefixesTest 91/108091/1
Robert Varga [Sun, 1 Oct 2023 14:51:12 +0000 (16:51 +0200)]
Clean up NamespacePrefixesTest

Now that we have moved decode(), we can specialize it to asserts,
cleaning things up a bit.

Change-Id: I073fde327587bcc78619b2c227f01a5f24057d40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoSimplify YT1108Test 71/108071/1
Robert Varga [Fri, 29 Sep 2023 19:13:11 +0000 (21:13 +0200)]
Simplify YT1108Test

Migrate to xmlunit-core and eliminate all the cruft we have surrounding
with setting up the comparison.

Change-Id: Iae46ece0c9c60bbb4d87a617dc7aed768d51b903
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRemove references to TestCase 70/108070/1
Robert Varga [Fri, 29 Sep 2023 19:00:37 +0000 (21:00 +0200)]
Remove references to TestCase

All we are doing is subclassing and routing to XMLAssert. Just route a
static call.

Change-Id: I786cef83dea43af0d10fab72da202a0989099acb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMigrate SchemaOrderedNormalizedNodeWriterTest 69/108069/1
Robert Varga [Fri, 29 Sep 2023 18:42:38 +0000 (20:42 +0200)]
Migrate SchemaOrderedNormalizedNodeWriterTest

Migrate one test case to xmlunit-core. Migrate the other test case to a
simple asserEquals() as it is a single line.

Change-Id: If2042c107b6200973de9945b74f8841c377b2639
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMigrate yang-model-export to xmlunit-core 66/108066/2
Robert Varga [Fri, 29 Sep 2023 17:09:49 +0000 (19:09 +0200)]
Migrate yang-model-export to xmlunit-core

Migrate legacy comparison, fixing up expected data, as we maintain the
proper order.

Change-Id: I0e243cd7ba4f95e7bd36b23a0fcd7592d08dfce7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoEliminate xmlunit-legacy from yang-data-impl 67/108067/2
Robert Varga [Fri, 29 Sep 2023 17:20:09 +0000 (19:20 +0200)]
Eliminate xmlunit-legacy from yang-data-impl

We have only a single unused class here, remove it and ditch dependency
on xmlunit.

Change-Id: I722c804b6a7c7dfcf15e077f718ba4b47b128086
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoEnforce mocking in yang-data-codec-xml tests 28/108028/11
Robert Varga [Thu, 28 Sep 2023 19:22:18 +0000 (21:22 +0200)]
Enforce mocking in yang-data-codec-xml tests

Pull in our mockito-configuration, so that we correctly mock all
interactions.

Change-Id: I065b44f7fc62a052475892738a310e7894962da6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUse YANG-derived prefixes 30/108030/15
Robert Varga [Thu, 28 Sep 2023 20:33:47 +0000 (22:33 +0200)]
Use YANG-derived prefixes

All XML examples starting from RFC6020 onwards use a module's prefix to
identify the module.

This is not something that is universally feasible to do, as the
document context may indicate a different namespace mapping, which may
be more efficient to use.

Such assignments may also conflict with already-assigned prefixes and
redefining XML namespaces increases cognitive load in analysis -- hence
we have to avoid that.

Also prefix assignments are not a global namespace, so we could easily
end up with ambigous mappings. This is unlikely, but it can easily
happen.

With an EffectiveModelContext we can perform analysis on what is valid
within that enclosed world and use that as a guide. When
NamespacePrefixes decides current RandomPrefix (which is not random at
all!) does not have a mapping, we can consult an analysis object to give
us guidance.

This patch renames RandomPrefix to 'NamespacePrefixes' and introduces
PreferredPrefixes, which can be computed from an EffectiveModelContext.

These two then act in unison to assign prefixes based on prefix
statements present in modules forming an EffectiveModelContext whenever
we need to do such a thing.

JIRA: YANGTOOLS-1544
Change-Id: Iafc5806f53d8927e46f059287e2ae3ed2c77ff26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up XML instance identifier class naming 26/108026/8
Robert Varga [Thu, 28 Sep 2023 17:39:39 +0000 (19:39 +0200)]
Clean up XML instance identifier class naming

Naming of things here is not great. We have two distinct implementations
of a full Codec, one of which can handle serialization and the other can
handle parsing.

Clean up naming, by having a top-level, fixed,
InstanceIdentifierXmlCodec, which is what we give users. We then have
InstanceIdentifier{Deserializer,Serializer}, which are bound, single-use
delegates.

This allows us to ditch the thread local stack we have been keeping to
deal with the fact that the implementation is directly internal.

Furthermore we optimize instantiation, so that we minimize the number of
calls to DataSchemaContextTree.from().

JIRA: YANGTOOLS-1543
Change-Id: I1ca884fe57086311111f12b3ba223d08f3676a93
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoFix XML instance identifier encoding 09/108009/10
Robert Varga [Thu, 28 Sep 2023 15:19:05 +0000 (17:19 +0200)]
Fix XML instance identifier encoding

XmlStringInstanceIdentifierCodec is not encoding prefixes properly. Use
the same trick we use for normal writeout.

Also improve mocking to cover all interactions we expect to happen.

JIRA: YANGTOOLS-1543
Change-Id: Ie018137599bd5a79db962da9573cbbca6bfc0599
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoMigrate RandomPrefixTest to JUnit5 29/108029/4
Robert Varga [Thu, 28 Sep 2023 19:45:46 +0000 (21:45 +0200)]
Migrate RandomPrefixTest to JUnit5

Hide the test and clean it up.

Change-Id: I7c5ddc6d04e40e42967089ccea9777347a4daa30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoReparent RandomPrefixInstanceIdentifierSerializer 27/108027/1
Robert Varga [Thu, 28 Sep 2023 18:33:54 +0000 (20:33 +0200)]
Reparent RandomPrefixInstanceIdentifierSerializer

We are the only direct subclass of
AbstractStringInstanceIdentifierCodec, which is a direct superclass of
AbstractModuleStringInstanceIdentifierCodec.

Use the latter as superclass, opening up the possiblity of merging the
two abstract classes.

Change-Id: Iee985fb54b102c4764fa4e9685652762db5265b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoClean up XmlStringInstanceIdentifierCodec instantiation 25/108025/1
Robert Varga [Thu, 28 Sep 2023 17:21:32 +0000 (19:21 +0200)]
Clean up XmlStringInstanceIdentifierCodec instantiation

We are inherently tied to the model context of our XmlCodecFactory.
Simplify the constructor and do not store the EffectiveModelContext.

Change-Id: I7676813295275926642018665908f11ec47f402b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not pass null to codec 18/108018/2
Robert Varga [Thu, 28 Sep 2023 17:06:20 +0000 (19:06 +0200)]
Do not pass null to codec

We are expecting a checked exception and are passing a null argument for
something which we are supposed to interact with. Use a proper mock for
argument. This will allow us to further extend verification should the
implementation change.

JIRA: YANGTOOLS-1543
Change-Id: I0f1defd442ae60ee9e9b1b7a43949eed320ac148
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoImprove YT1473Test stubbing 16/108016/3
Robert Varga [Thu, 28 Sep 2023 16:55:28 +0000 (18:55 +0200)]
Improve YT1473Test stubbing

Execute this test with MockitoExtension, which automatically verifies
all subbings. Refactor assertions accordingly.

JIRA: YANGTOOLS-1543
Change-Id: I099611b575f6a0775600c03e5f3edca41ff0bdd5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoModernize SchemaAwareXMLStreamWriterUtils a bit 13/108013/3
Robert Varga [Thu, 28 Sep 2023 16:02:36 +0000 (18:02 +0200)]
Modernize SchemaAwareXMLStreamWriterUtils a bit

Do not implemented EffectiveModelContextProvider to improve visibility
into invocations. Also use local variable type inference for brevity.

Change-Id: I3141562b0050435ed79f9bd06aa2dac03e59ec08
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoSimplify SchemaAwareXMLStreamNormalizedNodeStreamWriter 14/108014/1
Robert Varga [Thu, 28 Sep 2023 16:04:48 +0000 (18:04 +0200)]
Simplify SchemaAwareXMLStreamNormalizedNodeStreamWriter

There is no need to implement EffectiveModelContext provider here.

Change-Id: I39585b8dc2cefa844110ccf87aa52e9e925599f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoModernize SchemaAwareXMLStreamNormalizedNodeStreamWriter a bit 12/108012/1
Robert Varga [Thu, 28 Sep 2023 16:01:25 +0000 (18:01 +0200)]
Modernize SchemaAwareXMLStreamNormalizedNodeStreamWriter a bit

Use instanceof patterns to eliminate explicit casts.

Change-Id: I63e7dc828c03ea4110793b9dd86f0add1ac16c0a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoInline yt1107.xml 08/108008/1
Robert Varga [Thu, 28 Sep 2023 14:35:49 +0000 (16:35 +0200)]
Inline yt1107.xml

There is no need to keep this XML in a resource, inline it in its sole
user.

Change-Id: Ie8c99320c8c97263b502caed9e5de2a75ea11581
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoModernize XMLStreamWriterUtils 99/107999/1
Robert Varga [Wed, 27 Sep 2023 20:11:26 +0000 (22:11 +0200)]
Modernize XMLStreamWriterUtils

Use instanceof patterns and local variable type inference.

Change-Id: I13ace859c67f508955666d7a8f6599b66b083d96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoImprove context reporting 56/107956/1
Robert Varga [Fri, 22 Sep 2023 23:56:17 +0000 (01:56 +0200)]
Improve context reporting

If we fail at first step, we end up emitting an empty string, which
makes the output not nice. Quote the emitted string.

Change-Id: Ic54f7fd69a902de03205355b37fdc72d9979c051
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoReport checked exception in instance identifier writeout 55/107955/1
Robert Varga [Fri, 22 Sep 2023 23:33:03 +0000 (01:33 +0200)]
Report checked exception in instance identifier writeout

Both XML and JSON codecs are talking to a source of
IllegalArgumentExceptions. They should convert them to
XMLStreamException/IOException.

JIRA: YANGTOOLS-1542
Change-Id: Ia5ac633e37ed19c29d4593e2e886501c7baa59dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoBump versions to 11.0.3-SNAPSHOT 89/107889/1
Robert Varga [Sat, 16 Sep 2023 11:09:02 +0000 (13:09 +0200)]
Bump versions to 11.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: Id3564853cacd73318084422d35784225a2571627
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoRelease yangtools v11.0.2
jenkins-releng [Sat, 16 Sep 2023 06:51:43 +0000 (06:51 +0000)]
Release yangtools

8 months agoExpose JSONCodec and XmlCodec 79/107879/2
Robert Varga [Thu, 14 Sep 2023 19:55:17 +0000 (21:55 +0200)]
Expose JSONCodec and XmlCodec

We have a need to emit YangInstanceIdentifier values into raw writers.
We already have this capability exposed through
{JSON,Xml}Codec.writeValue().

This patch exposes that ability, forcing all AbstractCodecFactories to
do so.

JIRA: YANGTOOLS-1541
Change-Id: I854d67b6a1a57b6a8288c41db9714a3292fef093
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoRevert "Hide XmlCodecFactory internals" 78/107878/2
Robert Varga [Thu, 14 Sep 2023 19:56:20 +0000 (21:56 +0200)]
Revert "Hide XmlCodecFactory internals"

This reverts commit db06703aa3c1c68d9481b5823c16a570a23dfb6e. It is not
needed as we are about to expose XmlCodec.

JIRA: YANGTOOLS-1541
Change-Id: I861f0363d995517aa6a5a41f1e9077842379dfbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoIssue releaseFence() at the of ready() 94/107694/5
Robert Varga [Mon, 4 Sep 2023 20:35:22 +0000 (22:35 +0200)]
Issue releaseFence() at the of ready()

We seem to be observing stale state during modification validation. Make
sure we flush out any and all modifications before we complete ready().

Change-Id: I0f388d143526c96ff1684828dd16fc9ee681305b
JIRA: YANGTOOLS-1537
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoClean up checkSealed() 97/107697/5
Robert Varga [Mon, 4 Sep 2023 21:00:34 +0000 (23:00 +0200)]
Clean up checkSealed()

This method is mis-named, it should be called checkOpen(). Also use
an explicit if/throw to eliminate a negation.

Change-Id: Ia7baa03708711b8076ffdd512fbccacd906e3ffb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoUse Optional.isEmpty() 95/107695/3
Robert Varga [Mon, 4 Sep 2023 20:46:15 +0000 (22:46 +0200)]
Use Optional.isEmpty()

We have a number of calls to '!Optional.isPresent()'. Java 11 provides a
convenience Optional.isEmpty() for this case, so use that instead.

Change-Id: I519671f470d804e62bae07ec4c5a71aaa08a29f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoFix ModifiedNode.identifier nullness 91/107691/1
Robert Varga [Mon, 4 Sep 2023 18:06:12 +0000 (20:06 +0200)]
Fix ModifiedNode.identifier nullness

The identifier should always we present, enforce and annotate that.

Change-Id: I0bcebec56ab6fcee6b3c3b396dddbda92282729f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoMove ModifiedNode.IS_TERMINAL_PREDICATE 90/107690/2
Robert Varga [Mon, 4 Sep 2023 17:41:10 +0000 (19:41 +0200)]
Move ModifiedNode.IS_TERMINAL_PREDICATE

This predicate has a single user, inline it. Also modernize
InMemoryDataTreeModification while we are in the area.

Change-Id: I3cb15fbcb75d0a28c158256e3ef01e218b90dd2a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoDo not leak SupressFBWarnigs from YangNetconfError 84/107684/2
Robert Varga [Sun, 3 Sep 2023 21:42:22 +0000 (23:42 +0200)]
Do not leak SupressFBWarnigs from YangNetconfError

There is to suppress, do not leak the SuppressFBWarnigs.

Change-Id: I611f6315dad7febf0de0d4ea28581163d91a2850
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoAdd ValidatedTreeNode 79/107679/2
Robert Varga [Sun, 3 Sep 2023 21:10:01 +0000 (23:10 +0200)]
Add ValidatedTreeNode

We need to @SuppressFBWarnings a use of Optional<TreeNode> being
nullable. Replace Optional with a dedicated record, which provides
adaptation.

Change-Id: Idcd57cc899cacb09d7bec1711d0d084027716734
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoSeal ModificationApplyOperation 78/107678/2
Robert Varga [Sun, 3 Sep 2023 19:17:45 +0000 (21:17 +0200)]
Seal ModificationApplyOperation

We have a carefully-structured class hierarchy here. Make sure the JVM
understands it when performing partial loading.

Change-Id: Ie4b50be7127c7b103a84212d4674f017b1a9e5bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoUse an instanceof expression 75/107675/1
Robert Varga [Sun, 3 Sep 2023 19:01:59 +0000 (21:01 +0200)]
Use an instanceof expression

We have an-if-and-a-cast, use an instanceof expression instead.

Change-Id: Iee350a79fe740e2434ea1ce35071aa63315f1ae6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoImprove NodeModification 74/107674/1
Robert Varga [Sun, 3 Sep 2023 18:42:24 +0000 (20:42 +0200)]
Improve NodeModification

This is a faux-interface to split access. Seal it an allow it to be
implemented only by ModifiedNode.

Introduce NodeModification.isEmpty(), which short-circuits the access to
children.value(). Convert users to prefer this method over accessing
getChildren() -- i.e. moving the potential allocation further down.

Change-Id: Ibce631b729fd496374580be94902c2b18e55268f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoBump versions to 11.0.2-SNAPSHOT 86/107586/1
Robert Varga [Wed, 30 Aug 2023 13:39:39 +0000 (15:39 +0200)]
Bump versions to 11.0.2-SNAPSHOT

This starts the next development iteration.

Change-Id: I6499e714c15ed4995222ad6a968c3fc2e16dc5b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoRelease yangtools v11.0.1
jenkins-releng [Wed, 30 Aug 2023 12:21:44 +0000 (12:21 +0000)]
Release yangtools

8 months agoBump odlparent to 13.0.4 77/107577/2
Robert Varga [Wed, 30 Aug 2023 11:27:57 +0000 (13:27 +0200)]
Bump odlparent to 13.0.4

Pick up latest upgrades from upstream.

Change-Id: Ibb861e5d1d60784509f6d2ff79a51bcd9442a4d0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoFixup checkstyle in yang-repo-spi 76/107576/1
Robert Varga [Wed, 30 Aug 2023 11:38:44 +0000 (13:38 +0200)]
Fixup checkstyle in yang-repo-spi

Upgraded checkstyle is finding some violations, clean them up.

Change-Id: Iebc51805be902b15cc40e88c43e5c346e8936b6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoClean up EffectiveStatements 61/107561/2
Robert Varga [Tue, 29 Aug 2023 18:42:36 +0000 (20:42 +0200)]
Clean up EffectiveStatements

Centralize casting to make Sonar happy. While we are here, use
instanceof patterns to reduce explicit casts.

Change-Id: Ic3ff2c5a929ed7a9998aa34374510e2c535fca86
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoMove UintConversions.throwIAE() 60/107560/2
Robert Varga [Tue, 29 Aug 2023 18:26:22 +0000 (20:26 +0200)]
Move UintConversions.throwIAE()

We have a single caller in Uint64, inline it and make the exception
throw explicit. Fixes a few Sonar duplication complaints.

Change-Id: I7f5c246f45e591d514b7cd71afadcd55c4aa6af4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoUnify Decimal64 checks 59/107559/3
Robert Varga [Tue, 29 Aug 2023 18:15:38 +0000 (20:15 +0200)]
Unify Decimal64 checks

Sonar is pointing out string duplications. Take advantange of automatic
upcast-to-long to allocate the IAE/AE in a single place.

Change-Id: I8e8bc2003abe6ba2b31124aa6cff5afc6a901b02
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoFix NormalizedNodeContainerBuilder generics 58/107558/1
Robert Varga [Tue, 29 Aug 2023 18:03:36 +0000 (20:03 +0200)]
Fix NormalizedNodeContainerBuilder generics

We have quite a few inconsistencies with NormalizedNodeBuilder which we
are specializing. Align generic argument names to fix Sonar warnings.

Change-Id: I9a875f3de68c392997607198637660763742a60a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoMerge if statements 57/107557/1
Robert Varga [Tue, 29 Aug 2023 17:59:57 +0000 (19:59 +0200)]
Merge if statements

if() with an instanceof pattern can be merged with the if() using that
pattern's assigned variable.

Change-Id: I531231c04b180abd4096716f982efa7a6011c70c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoDo dot declare SAXException/URISyntaxException as thrown 22/107522/4
Robert Varga [Sun, 27 Aug 2023 09:41:00 +0000 (11:41 +0200)]
Do dot declare SAXException/URISyntaxException as thrown

We cannot throw this exception from the implementation, do not declare
it as thrown.

JIRA: YANGTOOLS-1535
Change-Id: I03e6bc96b66e3bba1739d8d26591dbaacad237ca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoHide XmlCodecFactory internals 26/107526/2
Robert Varga [Mon, 28 Aug 2023 11:15:55 +0000 (13:15 +0200)]
Hide XmlCodecFactory internals

We are getting warnings about leaking XmlCodec. While this is not
exactly true, mitigate these warnings by splitting the real logic
into a package-private class while retaining the same external
XmlCodecFactory facade.

JIRA: YANGTOOLS-1534
Change-Id: I719cf82f00d4580505d92d7126be6d2c09c26a4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoFix XML codec error reporting 19/107519/5
Robert Varga [Sat, 26 Aug 2023 20:59:58 +0000 (22:59 +0200)]
Fix XML codec error reporting

When we deal with anything ContainerLike, aside of ContainerSchemaNode
and ListNodeSchemaNode, we should just accept there is no support and
proceed to throw a descriptive exception.

JIRA: YANGTOOLS-1533
Change-Id: I7a173f3a21dd55d21e48570690427cee0c0ad16f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoSeal XmlCodec 20/107520/5
Robert Varga [Sat, 26 Aug 2023 21:13:12 +0000 (23:13 +0200)]
Seal XmlCodec

We require Java 17, make sure XmlCodec is sealed to be explicit about
what implementations are there.

JIRA: YANGTOOLS-1534
Change-Id: I12ca115663a06666345e956ea9b0901834d1c4c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoClean up Bug890Test 18/107518/1
Robert Varga [Sat, 26 Aug 2023 20:58:23 +0000 (22:58 +0200)]
Clean up Bug890Test

Use a multiline string to inline the XML and move the module to
top-level.

Change-Id: Ifda8d6f0fead26b5a813c8e28171032be12e9534
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoAdd Inference.isEmpty() 37/107437/1
Robert Varga [Wed, 16 Aug 2023 08:48:38 +0000 (10:48 +0200)]
Add Inference.isEmpty()

Downstreams need logic to adjust the inference unless it is empty.
Expose an isEmpty() method, which efficiently indicates whether the
inference is empty.

Change-Id: Ief6df4d8c2e1db34ea65bb6bdbd7e47525683dad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoUse switch expression in forElementBody() 31/107231/1
Robert Varga [Thu, 3 Aug 2023 15:54:28 +0000 (17:54 +0200)]
Use switch expression in forElementBody()

We have an utterly simple dispatch here. Eliminate the use of an
ImmutableMap and just make it a switch expression.

Change-Id: I3cfbfe2ed183b69cad35edc1abc129acb07c93a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoAdd DataSchemaContext.SimpleValue.type() 21/107021/2
Robert Varga [Mon, 24 Jul 2023 17:38:14 +0000 (19:38 +0200)]
Add DataSchemaContext.SimpleValue.type()

SimpleValues have an underlying TypeDefinition. Expose it so users
of DataSchemaContext can use that instead of going through the
underlying dataSchemaNode().

JIRA: YANGTOOLS-1529
Change-Id: I04bbb8e64913d140a29d96380ddc6ce4b5536fd8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoGuarantee @NonNull from TypeAware.getType() 22/107022/1
Robert Varga [Mon, 24 Jul 2023 18:08:14 +0000 (20:08 +0200)]
Guarantee @NonNull from TypeAware.getType()

The result is always non-null. Annotate that fact.

Change-Id: Ia18ef5058731c30d131772535b05a59cf38637ae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoMigrate rfc8528-parser-support to JUnit5 06/106906/4
matus.matok [Thu, 13 Jul 2023 08:34:52 +0000 (10:34 +0200)]
Migrate rfc8528-parser-support to JUnit5

Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks. Also modernize the test by
taking advantage of assertInstanceOf's return.

JIRA: YANGTOOLS-1521
Change-Id: Id1afcea13b04c7280cef1b48ebd5275ba917e6ed
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoMigrate rfc8040-parser-support to JUnit5 05/106905/4
matus.matok [Tue, 18 Jul 2023 11:05:23 +0000 (13:05 +0200)]
Migrate rfc8040-parser-support to JUnit5

Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks. Also modernize tests.

JIRA: YANGTOOLS-1521
Change-Id: I584ca427c2c4e2e8d2f928a4517d6e6d93475933
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoMigrate rfc7952-parser-support to JUnit5 04/106904/3
matus.matok [Thu, 13 Jul 2023 08:22:34 +0000 (10:22 +0200)]
Migrate rfc7952-parser-support to JUnit5

Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks. Also remove unneeded static
setup.

JIRA: YANGTOOLS-1521
Change-Id: I5bdd6507cb01198a5a57b9b553eaf59e679f6d71
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoMigrate rfc6643-parser-support to JUnit5 03/106903/4
matus.matok [Thu, 13 Jul 2023 08:18:46 +0000 (10:18 +0200)]
Migrate rfc6643-parser-support to JUnit5

Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks and modernize the tests.

JIRA: YANGTOOLS-1521
Change-Id: I748289df3fb3fbf7d8ce208b6304cc1438f0c41a
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoMigrate rfc6536-parser-support to JUnit5 02/106902/4
matus.matok [Thu, 13 Jul 2023 08:15:12 +0000 (10:15 +0200)]
Migrate rfc6536-parser-support to JUnit5

Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks. Also reduce the setup/teardown.

JIRA: YANGTOOLS-1521
Change-Id: I6c0fe859120a3f8a4319b92cbd4114c522912c91
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoMigrate rfc6241-parser-support to JUnit5 01/106901/4
matus.matok [Thu, 13 Jul 2023 08:10:49 +0000 (10:10 +0200)]
Migrate rfc6241-parser-support to JUnit5

Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks, and also modernizing the test.

JIRA: YANGTOOLS-1521
Change-Id: I7a87deb0d57c664b219e96258cb7254e80c30318
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoMigrate odlext-parser-support to JUnit5 00/106900/7
matus.matok [Thu, 13 Jul 2023 08:03:57 +0000 (10:03 +0200)]
Migrate odlext-parser-support to JUnit5

Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks. Also modernize the tests a bit
and remove unnecessary initialization.

JIRA: YANGTOOLS-1521
Change-Id: Ibedf49de7440857c66393db20ec7f1fe6d0a0429
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoReduce reliance on yang.model.api.Module 47/106947/3
Robert Varga [Fri, 21 Jul 2023 08:00:28 +0000 (10:00 +0200)]
Reduce reliance on yang.model.api.Module

Look up ModuleEffectiveStatement instead and derive returns from there.

JIRA: YANGTOOLS-1525
Change-Id: Ic6d61a69b50c938512a4cf6614777ac6bd46438a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoDo not trim element content for string leaf values 44/106944/6
Robert Varga [Thu, 20 Jul 2023 23:35:57 +0000 (01:35 +0200)]
Do not trim element content for string leaf values

Trimming element text leads to values being mis-represented -- for
example if the content is a YANG string, we really need to pick it up
directly.

We should completely avoid trimming, but that would lead to not
recognizing previously-accepted XML documents, for example those which
correspond to a uint8 with leading whitespace.

JIRA: YANGTOOLS-1522
Change-Id: Ib1e05a9428a66765b2f85cfde723fe27076f68ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoImprove XmlParserStream error reporting 46/106946/2
Robert Varga [Fri, 21 Jul 2023 05:04:55 +0000 (07:04 +0200)]
Improve XmlParserStream error reporting

When we encounter an unhandled schema, we should report ISE instead of
IAE to differentiate the two cases.

Change-Id: I9222f821a259ede5b8d56e5111297de565f01d2d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
9 months agoMigrate yang-parser-impl to JUnit5 08/106908/5
matus.matok [Thu, 13 Jul 2023 08:51:27 +0000 (10:51 +0200)]
Migrate yang-parser-impl to JUnit5

Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks. Also cleans up the affected
files to:
- use startsWith() test
- use assertThrows() instead of fail()
- local variable type inference

JIRA: YANGTOOLS-1521
Change-Id: Ieb9c37ecb6d409ad076c1012d14e194f022db311
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoAdd FluentFutures.submit() 09/106809/1
Robert Varga [Tue, 4 Jul 2023 19:28:54 +0000 (21:28 +0200)]
Add FluentFutures.submit()

This method mirrors Futures.submit(), but results in a FluentFuture.

Change-Id: Ie56ff26cb12a74b5021495cb33029c799d0cb721
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoCorrect Guava documentation link 76/106676/1
Robert Varga [Mon, 26 Jun 2023 12:10:43 +0000 (14:10 +0200)]
Correct Guava documentation link

Use guava.dev link and update to point to the correct version.

Change-Id: I0b302880e841437c72f417d16b57c25962f22607
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoBump versions to 11.0.1-SNAPSHOT 72/106672/1
Robert Varga [Mon, 26 Jun 2023 11:24:46 +0000 (13:24 +0200)]
Bump versions to 11.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: I6d75a15e8033ba8a5b1dbde33282d13a497329e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoRelease yangtools v11.0.0
jenkins-releng [Mon, 26 Jun 2023 10:21:07 +0000 (10:21 +0000)]
Release yangtools

10 months agoUpdate javadoc links 71/106671/1
Robert Varga [Mon, 26 Jun 2023 09:24:05 +0000 (11:24 +0200)]
Update javadoc links

Link to JUnit5 and use HTTPS.

Change-Id: If69656c7efa078097bd4ab1ea39142ca423eb1ca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoBump odlparent to 13.0.3 60/106660/2
Robert Varga [Fri, 23 Jun 2023 16:41:26 +0000 (18:41 +0200)]
Bump odlparent to 13.0.3

Pick up latest fixes.

Change-Id: I65997d7c9e2ab384d9562a9ea455d84157841077
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoUpdate get{ModifiedChild,DataAfter,DataBefore} 05/106605/2
Robert Varga [Wed, 21 Jun 2023 18:01:17 +0000 (20:01 +0200)]
Update get{ModifiedChild,DataAfter,DataBefore}

It is customary to require dataBefore/dataAfter. Repurpose the methods
to return a non-null-verified NormalizedNode. While we are at it, also
modify getModifiedChild().

JIRA: YANGTOOLS-1513
Change-Id: I90a3f1f2961b41d62c6d23afb434b40a45d75ccc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoMake warnings for unkeyed lists disabled by default 30/106530/3
Ruslan Kashapov [Mon, 19 Jun 2023 10:44:53 +0000 (13:44 +0300)]
Make warnings for unkeyed lists disabled by default

Making warnings for unkeyed list with config=true disabled
by default.

JIRA: YANGTOOLS-1423
Change-Id: I2b8e9a0abef8531d3b7853b029604a515e7196b8
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
10 months agoPromote util contracts 79/106579/1
Robert Varga [Wed, 21 Jun 2023 07:57:12 +0000 (09:57 +0200)]
Promote util contracts

Remove @Beta for sufficiently-stabilized classes.

Change-Id: Ie7bd239affcf1af1449413da9c69da0fc1a46a73
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoDeprecate EvenMoreObjects 78/106578/1
Robert Varga [Wed, 21 Jun 2023 07:52:13 +0000 (09:52 +0200)]
Deprecate EvenMoreObjects

This class is not used anywhere, deprecate it for removal.

Change-Id: I211d0fbec1791316335f52e57d5e3ff120250e4d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoDeprecate EffectiveAugmentationSchema 72/106572/1
Robert Varga [Wed, 21 Jun 2023 01:16:25 +0000 (03:16 +0200)]
Deprecate EffectiveAugmentationSchema

With AugmentatioNode gone from yang-data-api, we do not interact with
effective children anymore. Deprecate EffectiveAugmentationSchema for
removal.

JIRA: YANGTOOLS-1403
Change-Id: Iaca0f5e119d66f654361c6b08b01839626667d29
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoFix yang-data-codec-xml dependencies 53/106553/1
Robert Varga [Tue, 20 Jun 2023 12:30:36 +0000 (14:30 +0200)]
Fix yang-data-codec-xml dependencies

We are using rfc8040-model-api, make sure we declare it.

Change-Id: Idfe10dfe4cd441404a42eaaac39ad199a8763bf8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
11 months agoAdd DataSchemaContext.of(DataSchemaNode) 36/106536/2
Robert Varga [Mon, 19 Jun 2023 17:57:38 +0000 (19:57 +0200)]
Add DataSchemaContext.of(DataSchemaNode)

This factory method is still needed by downstreams, reintroduce it with
stricter semantics.

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