yangtools.git
10 days agoReuse cached factory
Robert Varga [Thu, 29 Jun 2023 12:07:41 +0000 (14:07 +0200)]
Reuse cached factory

We can take advantage of local factory to get the loader. This
simplifies things a bit.

Change-Id: Ic1b71c553bc2640697163a544809e1f5de873979
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoFix YangDataRuntimeTypes not being available
Robert Varga [Thu, 29 Jun 2023 11:18:03 +0000 (13:18 +0200)]
Fix YangDataRuntimeTypes not being available

CompositeRuntimeType children are always indexed only through
SchemaTree, which means we need to make another pass to get at
YangDataRuntimeTypes.

JIRA: MDSAL-805
Change-Id: I68cfc7fad2c1a7cb3333e48e9b435bc681992641
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoDo not require DataObject for streaming
Robert Varga [Wed, 28 Jun 2023 09:47:28 +0000 (11:47 +0200)]
Do not require DataObject for streaming

DataContainer is completely sufficient, require just that.

JIRA: MDSAL-805
Change-Id: Iff55143f2c3bcc8a4b678649285f170f0353db5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoReduce explicit casts in DataObjectStreamerGenerator
Robert Varga [Wed, 28 Jun 2023 09:20:20 +0000 (11:20 +0200)]
Reduce explicit casts in DataObjectStreamerGenerator

Use instanceof patterns to reduce casts.

Change-Id: I3d1e0f8ea5d4b14135e1604b6f902d9e5193941c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoFixup dom-codec a bit
Robert Varga [Wed, 28 Jun 2023 07:23:49 +0000 (09:23 +0200)]
Fixup dom-codec a bit

With all the moves we can tighten formatting a bit. Also remove a site
with raw types.

Change-Id: Id3b13500598a595517dbbfe9f98893517cd77aa2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename CaseNodeCodecContext
Robert Varga [Tue, 27 Jun 2023 22:06:41 +0000 (00:06 +0200)]
Rename CaseNodeCodecContext

'CaseCodecContext' is a better name, matching the CaseCodecPrototype we
already have.

Change-Id: I5b3f8501e92f65824d63da282b54b10751424208
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSplit up DataObjectCodecPrototype
Robert Varga [Tue, 27 Jun 2023 19:20:37 +0000 (21:20 +0200)]
Split up DataObjectCodecPrototype

Having a type-based dispatch during createInstance() is not exactly
nice. This patch splits up DataObjectCodecPrototype.createInstance()
into individual prototypes, so that we have a prototype for pretty-much
each CodecContext type.

This also improves type safety, as CodecContexts now can be directly
instantiated (and create a prototype internally).

Change-Id: If740949bc15890f0ce4bfa5b59cda030b33e66a1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename ContainerNodeCodecContext
Robert Varga [Tue, 27 Jun 2023 19:04:40 +0000 (21:04 +0200)]
Rename ContainerNodeCodecContext

A better name is 'ContainerLikeCodecContext', mirroring binding to
ContainerLikeRuntimeType.

Change-Id: Ie2579010a4b7da15df8192c0bd8690b84d769ccd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename NonPresenceContainerNodeCodecContext
Robert Varga [Tue, 27 Jun 2023 19:02:53 +0000 (21:02 +0200)]
Rename NonPresenceContainerNodeCodecContext

'StructuralContainerCodecContext' is a better name overall.

Change-Id: I8cec640b209b96929f1a9bc33bbfa6af3dde81e1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSplit up OpaqueNodeCodecContext
Robert Varga [Tue, 27 Jun 2023 15:38:01 +0000 (17:38 +0200)]
Split up OpaqueNodeCodecContext

We have two specializations, make promote them to top-level classes and
rename OpaqueNodeCodecContext to AbstractOpaqueCodecContext.

Change-Id: Ibe18324a5e5a408cfcf8bbbe6b77065f19a3bfa5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoPromote RuntimeType interface hierarchy
Robert Varga [Mon, 26 Jun 2023 21:48:01 +0000 (23:48 +0200)]
Promote RuntimeType interface hierarchy

Basic types have stood the test of time so far, drop @Beta annotations.

Change-Id: Icd8e8957706eb78678715a17653615de4b09d948
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoPromote BindingIdentityCodec
Robert Varga [Mon, 26 Jun 2023 20:25:29 +0000 (22:25 +0200)]
Promote BindingIdentityCodec

There is nothing @Beta about this interface anymore, remove the
annotation.

Change-Id: I6e8bedbc73b704566fce5ce06a9fb9316573cf5f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoAdd CodecWithPath documentation
Robert Varga [Mon, 26 Jun 2023 20:11:40 +0000 (22:11 +0200)]
Add CodecWithPath documentation

Document the two parts of this record.

Change-Id: Ia665ccda22f53944f760e1b3f22816e96b40faf1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoDrop @Beta from BindingCodecTree methods
Robert Varga [Mon, 26 Jun 2023 20:09:15 +0000 (22:09 +0200)]
Drop @Beta from BindingCodecTree methods

These methods are well-established, they are no longer @Beta.

Change-Id: I83770212cc6de6adf3d9f9c4d7880d923d5da00f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoDo not use BindingReflections in mdsal-binding-dom-codec-api
Robert Varga [Mon, 26 Jun 2023 18:33:35 +0000 (20:33 +0200)]
Do not use BindingReflections in mdsal-binding-dom-codec-api

The exact mechanics of now an Action's QNameModule is resolved should
not be dependent on reflection. Eliminate this assumption from API and
shift it down to implementation.

JIRA: MDSAL-781
Change-Id: I6c3a18c41ee8189c315be3cc2888c092f06bb6ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoReduce use of BindingReflections in BindingNormalizedNodeSerializer
Robert Varga [Mon, 26 Jun 2023 18:16:25 +0000 (20:16 +0200)]
Reduce use of BindingReflections in BindingNormalizedNodeSerializer

BindingNormalizedNodeSerializer's codec implementation can easily
process some of these methods and we therefore do not have to use
BindingReflections to acquire their NodeIdentifiers.

JIRA: MDSAL-781
Change-Id: If928d896e785fe8782ddbde7fb898464c40adb17
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove BindingReflections.getQName(BaseIdentity)
Robert Varga [Mon, 26 Jun 2023 18:03:02 +0000 (20:03 +0200)]
Remove BindingReflections.getQName(BaseIdentity)

All users (including downstreams) have been eliminated, remove this
method.

JIRA: MDSAL-781
Change-Id: I66a7dc55d86be4e863cff675f4feb230c5e4c531
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoFix output's NodeIdentifier
Robert Varga [Mon, 26 Jun 2023 18:36:32 +0000 (20:36 +0200)]
Fix output's NodeIdentifier

We are mis-representing the output as input, fix that.

Change-Id: Ic5eee44575e42b30ad60d75c3dd3256426ca9137
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoImprove binding-parent
Robert Varga [Mon, 26 Jun 2023 12:42:24 +0000 (14:42 +0200)]
Improve binding-parent

Require basic things for generated code and make sure
maven-dependency-plugin does not trip over optional parts.

Change-Id: I98d11bd165f5f85d324d27039e4c1b75974ee3ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoDo not require spotbugs transitively
Robert Varga [Mon, 26 Jun 2023 11:48:45 +0000 (13:48 +0200)]
Do not require spotbugs transitively

Clean up dependencies, eliminating unused declared dependencies on
spotbugs-annotations. Also clean up dependency confusion between
mdsal-binding-dom-adapter and mdsal-binding-test-utils.

Change-Id: Iaa6681c3e53ca8b9bd9e63abecf199b316fa9b4d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoBump upstreams
Robert Varga [Mon, 26 Jun 2023 08:36:01 +0000 (10:36 +0200)]
Bump upstreams

Adopt
- odlparent-13.0.3
- yangtools-11.0.0

Change-Id: Ie3277c61866d649a8c8c8bbde9320a0375cd65ab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoDo not use BindingReflections in ModuleInfoSnapshotBuilder
Robert Varga [Thu, 22 Jun 2023 15:53:32 +0000 (17:53 +0200)]
Do not use BindingReflections in ModuleInfoSnapshotBuilder

We have YangModuleInfos, which expose both the root package and the
corresponding namespace. Use that information to resolve QNameModule
for a particular root without relying on reflective access.

JIRA: MDSAL-783
Change-Id: If8b14cb49118f5d97c65783f29f1aa77bcc4eada
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoDo not use BindingReflections in IdentityCodec
Robert Varga [Thu, 22 Jun 2023 12:14:22 +0000 (14:14 +0200)]
Do not use BindingReflections in IdentityCodec

Instantiate a dedicated cache for holding object->QName mapping and use
that to service translation requests.

JIRA: MDSAL-783
Change-Id: I414a12f5f2a2e602a904d5dff0360ab0773dd26d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove BindingReflections.getQName(Rpc)
Robert Varga [Thu, 22 Jun 2023 12:53:29 +0000 (14:53 +0200)]
Remove BindingReflections.getQName(Rpc)

This method is not used anywhere, remove it.

JIRA: MDSAL-783
Change-Id: I2b76a8fd91bc99382933311cc0eb6aa3c2c72dd4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoHide BindingReflections.isRpcType()
Robert Varga [Thu, 22 Jun 2023 10:32:01 +0000 (12:32 +0200)]
Hide BindingReflections.isRpcType()

This method is only used internally, do not expose it to the outside
world.

JIRA: MDSAL-781
Change-Id: If3dd90eaa24179559e830ebbded5a206ff76082a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename yang.binding.{Identifiable,Identifier}
Robert Varga [Wed, 21 Jun 2023 15:14:27 +0000 (17:14 +0200)]
Rename yang.binding.{Identifiable,Identifier}

Key represents the base to which we usually bind, implying also
Map.get(key). KeyAware is a good name for an interface defining key()
method.

JIRA: MDSAL-830
Change-Id: I7e5b6e3a8f50daed6799164425a7f394b82fdef5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoMove BindingReflections.isNotificationCallback()
Robert Varga [Wed, 21 Jun 2023 12:49:39 +0000 (14:49 +0200)]
Move BindingReflections.isNotificationCallback()

This method has only one user, mdsal-binding-dom-adapter. Move it there.

JIRA: MDSAL-781
Change-Id: I128d588d58a75e00b63ebdbba6f503dd261646c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove BindingReflections.isRpcMethod()
Robert Varga [Wed, 21 Jun 2023 12:40:58 +0000 (14:40 +0200)]
Remove BindingReflections.isRpcMethod()

This method is not used anywhere, remove it.

JIRA: MDSAL-781
Change-Id: I706eac66d496ae8f52c9a98b004d1906e6165e43
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove BindingReflections.getModuleInfoClassName()
Robert Varga [Wed, 21 Jun 2023 12:35:52 +0000 (14:35 +0200)]
Remove BindingReflections.getModuleInfoClassName()

This is a trivial method, used only internally. Remove it by inlining it
into its sole user.

JIRA: MDSAL-781
Change-Id: Iaf39afde3ef7463744d06691e9cbcc2dc43de672
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove BindingReflections.loadModuleInfos()
Robert Varga [Wed, 21 Jun 2023 12:19:38 +0000 (14:19 +0200)]
Remove BindingReflections.loadModuleInfos()

The only user here has been migrated BindingRuntimeHelpers, remove the
binding-spec-util conterpart.

JIRA: MDSAL-781
Change-Id: I14e61e7a45f80a78c3d508e22d9555105817afbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoMove BindingReflections.cacheModuleInfos()
Robert Varga [Wed, 21 Jun 2023 12:16:30 +0000 (14:16 +0200)]
Move BindingReflections.cacheModuleInfos()

This caching is only used in AbstractSchemaAwareTest, move them there.

JIRA: MDSAL-781
Change-Id: Id0f9d16f5ec046e7b545486aabbfca7e706b9f2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoMove BindingReflections.findAugmentationTarget()
Robert Varga [Wed, 21 Jun 2023 12:07:53 +0000 (14:07 +0200)]
Move BindingReflections.findAugmentationTarget()

This method is only used in mdsal-binding-dom-codec, move it there.

JIRA: MDSAL-781
Change-Id: I0ee82715a0d69ddcf2f7daaca1ec7e7a2b2012bd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoHide BindingReflections.getModuleInfo()
Robert Varga [Wed, 21 Jun 2023 11:45:57 +0000 (13:45 +0200)]
Hide BindingReflections.getModuleInfo()

We have a replacement in BindingRuntimeHelpers.getYangModuleInfo(). This
patch migrates users and eliminates getModuleInfo() from public view.

JIRA: MDSAL-781
Change-Id: Ifd1cdbee440e8f14c1f53b2432b3b8cf3a7fc8df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove BindingReflections.getModelRootPackageName()
Robert Varga [Wed, 21 Jun 2023 11:32:58 +0000 (13:32 +0200)]
Remove BindingReflections.getModelRootPackageName()

This method was moved to yang.binding.contract.Naming, remove it.

JIRA: MDSAL-781
Change-Id: I300363accd91908a648cb78294ffc7043f93e812
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove DataObjectReadingUtil
Robert Varga [Wed, 21 Jun 2023 11:18:17 +0000 (13:18 +0200)]
Remove DataObjectReadingUtil

This class has been deprecated for quite some time and has no users.
Remove it.

JIRA: MDSAL-801
Change-Id: I3f29ab770f696f4fa75092ddc0af93d665c004ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoAdd simple data listeners
Oleksandr Panasiuk [Tue, 28 Mar 2023 09:36:14 +0000 (12:36 +0300)]
Add simple data listeners

DataTreeChangeListener is a rather complex contract, where users
sometimes want to receive only the latest state or the delta of the
state.

Add DataListener, which reports the current value and
DataChangeListener, which reports changes.

JIRA: MDSAL-813
Change-Id: I7db024f76709b9d4afcc0db5cbca3f1d35218e3f
Signed-off-by: Oleksandr Panasiuk <oleksandr.panasiuk@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoClean up mdsal-binding-runtime-spi dependencies
Robert Varga [Tue, 20 Jun 2023 22:23:01 +0000 (00:23 +0200)]
Clean up mdsal-binding-runtime-spi dependencies

We are using JDT annotations, make that explicit.

Change-Id: Ib31a9e7920fdd765a442a9ed778881b8477ac778
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoFix BindingRuntimeHelper.extractYangModuleInfo()
Robert Varga [Tue, 20 Jun 2023 21:39:16 +0000 (23:39 +0200)]
Fix BindingRuntimeHelper.extractYangModuleInfo()

Previous patch has broken the extraction facility in multi-classloader
environments: when we have a Class, we should be using its ClassLoader,
not TCCL, to locate its sibling.

JIRA: MDSAL-803
Change-Id: Ie3684a6defeaf51c6c98efcf48791b677b2ef2f1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoClean up dependencies
Robert Varga [Tue, 20 Jun 2023 12:42:53 +0000 (14:42 +0200)]
Clean up dependencies

We have a ton of warnings, reign some of them in.

Change-Id: I4aa0b3871f9416c09fb17fe5f9325015231ac40a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoEliminate DataObjectSerializerImplementation
Robert Varga [Tue, 20 Jun 2023 10:14:57 +0000 (12:14 +0200)]
Eliminate DataObjectSerializerImplementation

We do not need the intermediate interface and can just have
DataObjectStreamer as the main entrypoint.

Change-Id: I14b01652baf5c0c6bd86ffe3951255717b2bd831
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoHide DataObjectSerializer
Robert Varga [Tue, 20 Jun 2023 10:09:14 +0000 (12:09 +0200)]
Hide DataObjectSerializer

Promote this class to a hidden implementation detail.

Change-Id: Ibf48f98cd9b9175b8a22eca102bbeb6162ccac67
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoFix BindingToNormalizedStreamWriter.enter()
Robert Varga [Tue, 20 Jun 2023 09:46:01 +0000 (11:46 +0200)]
Fix BindingToNormalizedStreamWriter.enter()

We have a blind cast which does not handle augmentations' children. Fix
the cast to work for augmentations as well.

JIRA: MDSAL-820
Change-Id: Ib32a65e475d5d786bcc0d353f5fe044c147e4c07
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoAdd BindingDataObjectCodecTreeParent.getStream{Augmentation,DataObject}
Robert Varga [Tue, 20 Jun 2023 01:08:25 +0000 (03:08 +0200)]
Add BindingDataObjectCodecTreeParent.getStream{Augmentation,DataObject}

When we know we are streaming to a particular type, we can improve the
user experience by returning a friendly interface.

JIRA: MDSAL-820
Change-Id: Iadb85de866a0446934f636bb870e1df5f4c81a4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoAdd CommonDataObjectCodecTreeNode.stream{Augmentation,DataObject}
Robert Varga [Tue, 20 Jun 2023 01:08:25 +0000 (03:08 +0200)]
Add CommonDataObjectCodecTreeNode.stream{Augmentation,DataObject}

When we know we are streaming to a particular type, we can improve the
user experience by returning a friendly interface.

JIRA: MDSAL-820
Change-Id: I89d8dbed493919a72db7195213c5cf688b9ecb5a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRehost BindingReflections.loadModuleInfos()
Oleksandr Panasiuk [Tue, 14 Mar 2023 16:06:33 +0000 (18:06 +0200)]
Rehost BindingReflections.loadModuleInfos()

Use ServiceLoader to locate all module infos instead. This reduces the
proliferation of BindingReflections just a tiny bit.

JIRA: MDSAL-803
Change-Id: I5d76f6c8eddc1d689ebd8fcbe9cbf23350b465cf
Signed-off-by: Oleksandr Panasiuk <oleksandr.panasiuk@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoPromote AbstractBindingLazyContainerNode
Robert Varga [Wed, 14 Jun 2023 19:41:09 +0000 (21:41 +0200)]
Promote AbstractBindingLazyContainerNode

This is a well-proven class, drop the @Beta annotation and clean in up a
bit.

Change-Id: I7d6bd3e4717dd969695c58fe52e71d38911a4a24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove unused dependency
Robert Varga [Wed, 14 Jun 2023 13:33:57 +0000 (15:33 +0200)]
Remove unused dependency

mdsal-binding-spec-util is not used by mdsal-binding-generator, remove
the dependency.

Change-Id: I3ac0264bc32f52ab311c1e1c951293bc49b7a789
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoIntroduce AbstractBaseTemplate
Robert Varga [Sun, 28 May 2023 20:24:49 +0000 (22:24 +0200)]
Introduce AbstractBaseTemplate

Pull down some of the more obvious methods from BaseTemplate to an
abstract class. This improves things by introducing static methods
and having them in Java.

JIRA: MDSAL-562
Change-Id: I1b04477695c7a966e7a829e67d0340c8a551d7f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoHide DataContainerCodecContext.getType()
Robert Varga [Thu, 15 Jun 2023 14:08:37 +0000 (16:08 +0200)]
Hide DataContainerCodecContext.getType()

This method is used only internally, hide it from public view.

Change-Id: Id1700333937155fb5eff6cecca630fcff7c6bced
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoConvert mdsal-binding-runtime-osgi to a JPMS module
Robert Varga [Fri, 16 Jun 2023 09:57:12 +0000 (11:57 +0200)]
Convert mdsal-binding-runtime-osgi to a JPMS module

Ditch Automatic-Module-Name and instead provide a proper module.

JIRA: MDSAL-619
Change-Id: I940072ba15c14a73b918f41c11c80a85e31aa872
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoClean up mdsal-binding-model-api dependencies
Robert Varga [Thu, 15 Jun 2023 13:09:49 +0000 (15:09 +0200)]
Clean up mdsal-binding-model-api dependencies

We are not using yang-common here, fix that up.

Change-Id: I7ebc0e7983710bb870a90d0c6697baf8822d0034
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoExport org.opendaylight.mdsal.binding.dom.codec.impl
Robert Varga [Thu, 15 Jun 2023 08:49:19 +0000 (10:49 +0200)]
Export org.opendaylight.mdsal.binding.dom.codec.impl

As a stop-gap measure, expose the entire top-level artifact. This will
be tied down in later patches.

JIRA: MDSAL-828
Change-Id: I5fb61aa595ee2b66e99f3833cfc6935d8d529ffb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoBump xtend to 2.31.0
Robert Varga [Wed, 14 Jun 2023 20:53:49 +0000 (22:53 +0200)]
Bump xtend to 2.31.0

https://www.eclipse.org/xtend/releasenotes.html#/releasenotes/2023/05/29/version-2-31-0

Change-Id: Icbb185327e80d55d0b8306ed786ccc2be6f1ef6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRefactor streamChild() methods
Robert Varga [Wed, 14 Jun 2023 22:05:02 +0000 (00:05 +0200)]
Refactor streamChild() methods

We have a tad confusing naming, where the individual methods are
related. Unify naming.

Change-Id: Iba8c725f611308da65761fce9a4249642963901a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoClean up addYangPathArgument()
Robert Varga [Wed, 14 Jun 2023 20:38:45 +0000 (22:38 +0200)]
Clean up addYangPathArgument()

The nullability is confused here. Make sure we separate the two
invocation paths, so that we check builder for non-null as few times as
practicable.

Change-Id: Iceafa279fb3b69ffdaa54d4250ecf370edaa2622
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename AugmentatioNodeContext
Robert Varga [Wed, 14 Jun 2023 19:54:08 +0000 (21:54 +0200)]
Rename AugmentatioNodeContext

The 'Node' word does not really tell us much. Rename to
AugmentationCodecContext.

JIRA: MDSAL-828
Change-Id: Ib2e0487cfda365570bf01e9bcd474a59c8bc42d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoFix code generation with leafrefs pointing to optional members
Robert Varga [Tue, 13 Jun 2023 14:57:25 +0000 (16:57 +0200)]
Fix code generation with leafrefs pointing to optional members

When we have a typedef which points to a location disabled by
if-feature, we need to accept this fact -- but do not allow that typedef
to be referenced.

JIRA: MDSAL-829
Change-Id: Ibde28faa2f96904dc16fcc6f5a922edc6bcffebb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoGuard against null augmentations
Robert Varga [Tue, 13 Jun 2023 14:17:59 +0000 (16:17 +0200)]
Guard against null augmentations

Do not populate the augmentations map with null values.

JIRA: MDSAL-820
Change-Id: I3258337f1c9dd782b840e9ebad4e154428afc53b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove an unnecessary cast
Robert Varga [Tue, 13 Jun 2023 14:10:38 +0000 (16:10 +0200)]
Remove an unnecessary cast

We know the getDomPathArgument() always returns NodeIdentifier, there is
no need to cast it.

Change-Id: Ic525f0938e692251a8bff0c80dd90e40966d926f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename ChoiceNodeCodecContext
Robert Varga [Tue, 13 Jun 2023 13:25:40 +0000 (15:25 +0200)]
Rename ChoiceNodeCodecContext

ChoiceCodecContext is a better and shorter name, as the 'Node' part does
not really make any sense.

JIRA: MDSAL-828
Change-Id: Ied868e2cecda87ccdd69dae9f6688c7d70cac924
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename SchemaRootCodecContext
Robert Varga [Tue, 13 Jun 2023 13:23:40 +0000 (15:23 +0200)]
Rename SchemaRootCodecContext

SchemaRoot is too long a name, shorten in to RootCodecContext.

JIRA: MDSAL-828
Change-Id: I01a7d87e20ec4c073624a2cf1367ab2c369cb574
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoHide CodecOpaqueObject constructor
Robert Varga [Tue, 13 Jun 2023 12:43:41 +0000 (14:43 +0200)]
Hide CodecOpaqueObject constructor

We no longer use Javassist, hence we can just make the constructor
protected.

Change-Id: I760fc93f613c3593e72373b12c904cd6d149d525
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoImprove AbstractOpaque{Data,Object}.equals()
Robert Varga [Tue, 13 Jun 2023 12:40:39 +0000 (14:40 +0200)]
Improve AbstractOpaque{Data,Object}.equals()

Use instanceof pattern to simplify equals() method.

Change-Id: I04f8262428b0a6a1ef8d35c21793c51306b9ed81
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename NodeCodecContext
Robert Varga [Tue, 13 Jun 2023 12:09:34 +0000 (14:09 +0200)]
Rename NodeCodecContext

This name is awefully long and the 'Node' part does not convey any
meaning. Rename it to CodecContext.

JIRA: MDSAL-828
Change-Id: I31e93a49d79f31e3d43bc803639393c8e9e6c8d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSeal NodeCodecContext hierarchy
Robert Varga [Tue, 13 Jun 2023 11:53:05 +0000 (13:53 +0200)]
Seal NodeCodecContext hierarchy

We are about split out some of the contexts to public places. Before we
do that, though, make sure the hierarchy is sealed, so we do not get
accidental subclasses.

JIRA: MDSAL-828
Change-Id: Iaa1f0954eb1e571b08dbe8760157a996c1905143
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSplit out CodecContextFactory
Robert Varga [Tue, 13 Jun 2023 11:31:35 +0000 (13:31 +0200)]
Split out CodecContextFactory

The coupling of CodecContextFactory to NodeCodecContext prevents proper
splitting the individual concerns. Promote CodecContextFactory to a
top-level class.

JIRA: MDSAL-828
Change-Id: Ic3cc54380e7db76e92c116103b84af209625e97b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSeal IdentifiableItemCodec
Robert Varga [Tue, 13 Jun 2023 10:48:19 +0000 (12:48 +0200)]
Seal IdentifiableItemCodec

We have only two concrete subclasses, make sure the JVM knows that.

Change-Id: Ic9121d08ce6ca6140918bac001132ba68681b32e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoAdjust to YangTextSchemaSource being a CharSource
Robert Varga [Tue, 13 Jun 2023 10:18:39 +0000 (12:18 +0200)]
Adjust to YangTextSchemaSource being a CharSource

YANGTOOLS-1508 changed the interface here, adjust to it by using
delegateForCharSource() instead.

Change-Id: I20327d4ff7b8f023f18755104ef9b9b581fd24c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRename CaseNodeCodecContext.Prototype
Robert Varga [Mon, 5 Jun 2023 08:05:39 +0000 (10:05 +0200)]
Rename CaseNodeCodecContext.Prototype

Split this class out into CaseCodecPrototype top-level class.

Change-Id: I9b94a07f5b78bdec684d17ed0831e67a06cf0c0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSplit out CaseNodeCodecContext.Prototype
Robert Varga [Sun, 4 Jun 2023 22:47:14 +0000 (00:47 +0200)]
Split out CaseNodeCodecContext.Prototype

Add an explicit subclass of DataObjectCodecProtype to serve case nodes.

Change-Id: I77a752be75673d1ffa768c5d76c422f082e03880
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSplit out NotificationCodecContext.Prototype
Robert Varga [Sun, 4 Jun 2023 21:47:46 +0000 (23:47 +0200)]
Split out NotificationCodecContext.Prototype

Notifications require a special context, split them out and guard
against re-instantiation.

Change-Id: I7eede21b2aeab92c02ae451a4c5e341361563bca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSplit out SchemaRootCodecContext.Prototype
Robert Varga [Sun, 4 Jun 2023 21:13:49 +0000 (23:13 +0200)]
Split out SchemaRootCodecContext.Prototype

This prototype is rather special, split it out, making the dependency
graph a tad simpler.

Change-Id: I8da7e556fdb73f729b054bfb28dbcaa57e577aeb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSplit out DataContainerCodecPrototype subclasses
Robert Varga [Sun, 4 Jun 2023 20:57:06 +0000 (22:57 +0200)]
Split out DataContainerCodecPrototype subclasses

We are going to ditch the Regular specialization in favor of providing
proper specializations. Take the first step and promote the two
specializations to top-level classes.

Change-Id: I0d350c0f1b0c1e364cd4330a39a51ec01e9c9dbd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoUse instanceof patterns in KeyedListNodeCodecContext
Robert Varga [Sun, 4 Jun 2023 20:15:11 +0000 (22:15 +0200)]
Use instanceof patterns in KeyedListNodeCodecContext

Reduce explicit casts by using instanceof expressions.

Change-Id: I04c15c70b0c9b23680aeb07892cc11c1b167b07f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoUse instanceof patterns in CodecDataObject
Robert Varga [Sun, 4 Jun 2023 20:13:50 +0000 (22:13 +0200)]
Use instanceof patterns in CodecDataObject

Throw explicit VerifyExceptions instead of verify(... instanceof ...),
so we make it obvious what is going on.

Change-Id: I2fef6be328eb99b2f7c5e6082ad637be0374a17f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoSharpen CodecDataObject.data
Robert Varga [Sun, 4 Jun 2023 19:51:49 +0000 (21:51 +0200)]
Sharpen CodecDataObject.data

Since we do not have AugmentationNodes, we now know that all
DistinctNodeContainers backing CodecDataObject are DataContainerNodes.
Sharpen the contract, which gets rid of some ugliness around generic
arguments.

Change-Id: I097e6fda0ca312fc808f2ac2d4e0bbc6ac679315
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoModernize dom-codec-api a bit
Robert Varga [Sun, 4 Jun 2023 19:11:18 +0000 (21:11 +0200)]
Modernize dom-codec-api a bit

With AugmentationNode out of the picture, we know that
DataContainerChild nodes are identified by NodeIdentifier. Codify that
instead of working with plain PathArguments.

Change-Id: I50501e16ac33d3d4e49768b6ff8275603820fb3b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoModernize ChoiceNodeCodecContext
Robert Varga [Sun, 4 Jun 2023 18:59:58 +0000 (20:59 +0200)]
Modernize ChoiceNodeCodecContext

We know that Choice's components can only be addressable by
NodeIdentifier, make sure we reflect in the byYangCaseChild Map.
Also use local variable type inference and a text block.

Change-Id: I7ac024b5791247685ecf05e9f77040919eec1219
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoBump odlparent to 13.0.0
Robert Varga [Tue, 30 May 2023 20:01:55 +0000 (22:01 +0200)]
Bump odlparent to 13.0.0

Align the version with the version used by yangtools-11. Also fixes up
dependencies to pull in optional annotations.

Change-Id: Ia2ef118df94d7ca6c87de28834e1977d3fc41a13
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoImprove BindingNormalizedNodeSerializer API
Robert Varga [Sun, 28 May 2023 15:26:11 +0000 (17:26 +0200)]
Improve BindingNormalizedNodeSerializer API

Allow users to specifically ask for an explicit dataobject or
augmentation serialization.

JIRA: MDSAL-820
Change-Id: Ic929620d2c23c8ac1ab7eb7a5f2f46d627833a73
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoClean up BindingAugmentationCodecTreeNode
Robert Varga [Sun, 28 May 2023 14:03:06 +0000 (16:03 +0200)]
Clean up BindingAugmentationCodecTreeNode

We have two unused methods here, remove them.

JIRA: MDSAL-820
Change-Id: Ib1f1fc145f2a5d38cce40f1e1ddee6058d0860e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoImprove BindingCodecTree interface
Robert Varga [Sun, 28 May 2023 13:50:41 +0000 (15:50 +0200)]
Improve BindingCodecTree interface

We have users which know statically that they are dealing with a plain
DataObject or an Augmentation. Add methods to help them to get the right
codec.

JIRA: MDSAL-820
Change-Id: Idf0209c9dc705cf8359688a0eef2dd2e9fa00df2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove binding.spec.util package
Šimon Ukuš [Mon, 23 Jan 2023 06:51:17 +0000 (07:51 +0100)]
Remove binding.spec.util package

Deprecated DataObjectReadingUtil is not being used by anyone.

JIRA: MDSAL-801
Change-Id: I33d68733820c200155c99f0d0f703daff450e411
Signed-off-by: Šimon Ukuš <simon.ukus@pantheon.tech>
10 days agoMigrate users of NormalizedNode.getIdentifier()
Robert Varga [Sun, 28 May 2023 13:08:37 +0000 (15:08 +0200)]
Migrate users of NormalizedNode.getIdentifier()

We have a replacement, NormalizedNode.name(), use that instead.

Change-Id: Iebcca6dde477b7e5c8dd74dc577e68abbee07662
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoMigrate callers of IncorrectNestingException.create()
Robert Varga [Sun, 28 May 2023 13:03:34 +0000 (15:03 +0200)]
Migrate callers of IncorrectNestingException.create()

The static factory method is quite useless, migrate aware from it.

Change-Id: I386d8d13585b8a1627460615e8c84772fe9e21a1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoMigrate users of YangInstanceIdentifier.{create,empty}()
Robert Varga [Sun, 28 May 2023 12:54:27 +0000 (14:54 +0200)]
Migrate users of YangInstanceIdentifier.{create,empty}()

We have of() methods to replace these, migrate users.

Change-Id: I041a20ee6dd0bbb56ee765ecf2788517bd6318d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoAdopt yangtools-11.0.0-SNAPSHOT
Robert Varga [Sat, 25 Feb 2023 10:50:36 +0000 (11:50 +0100)]
Adopt yangtools-11.0.0-SNAPSHOT

yangtools is finalizing its bits, which have reprecussions on MD-SAL
APIs. Synchronize with current snapshot so we can start addressing those
bits.

Change-Id: I7d331e28ace9c8b512f960f4452da1fa8d178d05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
10 days agoUpdate binding-dom adaptation to remove AugmentationNode
Robert Varga [Mon, 22 May 2023 12:04:24 +0000 (14:04 +0200)]
Update binding-dom adaptation to remove AugmentationNode

AugmentationIdentifier and AugmentationNode are being removed from
yang-data-api.

This patch adapts mdsal-binding-dom-codec to reflect the
fact Augmentation no longer has one-to-one equivalent. This means that
users need to check whether the code tree node refers to an Augmentation
or to a regular DataObject.

One particular sore point is that toNormalized() can no longer return a
plain Entry of NormalizedNode, as Augmentations do not have a backing.
To solve this, we introduce NormalizedResult with two specializations,
NodeResult and AugmentationResult.

In order to deal with DTCL changes, we also memoize
dataBefore/dataAfter, as it guides LazyAugmentationModification's
correct identification whether the a node has appeared, was modified, or
disappeared.

JIRA: MDSAL-820
Change-Id: I0360fd8f74ddb6df82ba64f7a87f6d92ce855162
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoBump upstreams
Robert Varga [Fri, 26 May 2023 21:02:38 +0000 (23:02 +0200)]
Bump upstreams

Adopt:
- odlparent-12.0.6
- yangtools-10.0.7

Change-Id: I509da62c6d136ff66a12d99348389be0aa626b19
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d9064e5627264882f4efca2409eb5e3f6dad27a0)

10 days agoImprove BindingCodecTree.getSubtreeCodec()
Robert Varga [Fri, 26 May 2023 21:51:09 +0000 (23:51 +0200)]
Improve BindingCodecTree.getSubtreeCodec()

The only implementation we have returns non-null and throws exceptions.
Promote that behaviour to how the method is meant to operate.

Change-Id: I836ee8adb20d23b7b9938dbdeb827aa7a5443bc2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoImprove BindingCodecContext.getCodecContextNode()
Robert Varga [Fri, 26 May 2023 21:45:56 +0000 (23:45 +0200)]
Improve BindingCodecContext.getCodecContextNode()

This method always returns @NonNull, document that. Also improve the IAE
thrown on mismatched input and eliminate
SchemaRootCodecContext.create().

Change-Id: Icbd36df64fb5027698a80bd0ba0984b9f55777d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoDitch use of LinkedList in BindingCodecContext
Robert Varga [Thu, 25 May 2023 15:12:33 +0000 (17:12 +0200)]
Ditch use of LinkedList in BindingCodecContext

LinkedList is a rather ugly thing performance-wise, use an ArrayList
instead.

Change-Id: I6f40a24bc7b22dc07ea6c809a44a796f1cdb9b54
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoModernize BindingCodecContext
Robert Varga [Thu, 25 May 2023 13:11:33 +0000 (15:11 +0200)]
Modernize BindingCodecContext

Use local variable type inference and instanceof patterns to make things
a tad clearer.

Change-Id: I4b0e2634a08edb2f73e4586356d380063520fc48
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoAdd CodecDataObjectAnalysis
Robert Varga [Mon, 22 May 2023 22:14:55 +0000 (00:14 +0200)]
Add CodecDataObjectAnalysis

We will be separating out DataObjectCodecContext into two classes, and
the new one will need to be able to create proxies.

Separate out all the analytics and indexing into a separate DTO, which
can be constructed externally, so the new classes can construct them
separately.

This also necessitates splitting out bindingChildArg() into a separate
class -- but we still want to migrate that to RuntimTypes at some point.

JIRA: MDSAL-820
Change-Id: I970b8f92443a9faf57c1786239e2f552f7ff938d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoClean up DataContainerCodecContext exception handling
Robert Varga [Mon, 22 May 2023 23:13:00 +0000 (01:13 +0200)]
Clean up DataContainerCodecContext exception handling

We are getting confused between immediate throws and returns. The
exception factory methods should be returning the exception and not
throwing it.

Fix this up and add a SpotBugs annotation so that throws are guarded.
Also mark IncorrectNestingException for evolution. Final improvement
that we now have a completely-static factory method.

Change-Id: I5262c0dbb31d6935f258909828aac5331c70801b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoImprove DataContainerCodecPrototype safety
Robert Varga [Mon, 22 May 2023 17:52:12 +0000 (19:52 +0200)]
Improve DataContainerCodecPrototype safety

Before making any changes to the codec, make sure the prototype enforces
invariants, so things like nulls do not sneak in.

JIRA: MDSAL-820
Change-Id: I6c15f686bfde20b5f4516d9ad0b0f40007d689c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoClean up NonCachingCodec
Robert Varga [Mon, 22 May 2023 16:49:15 +0000 (18:49 +0200)]
Clean up NonCachingCodec

Use requireNonNull() and make the codec final, as it is only used as-is.

Change-Id: I59c25c4bcf795e193ac7af764cee9fa868c8435f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoisSubstitutionFor() should be final
Robert Varga [Mon, 22 May 2023 16:09:18 +0000 (18:09 +0200)]
isSubstitutionFor() should be final

Having a static final method guards against potential overlaps, which is
exactly what we want.

Change-Id: I557b80251f5472e57c0ba86853e30d498c515d8a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoRemove BindingDataObjectCodecTreeNode.writeAsNormalizedNode()
Robert Varga [Mon, 22 May 2023 12:12:10 +0000 (14:12 +0200)]
Remove BindingDataObjectCodecTreeNode.writeAsNormalizedNode()

This is a leak of implementation internals, not used anywhere but inside
the implementation.

JIRA: MDSAL-820
Change-Id: I3869dd490eb94f218ea86ff7b164ac05f2f5a9e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 days agoMove addYangPathArgument()
Robert Varga [Fri, 21 Apr 2023 00:04:11 +0000 (02:04 +0200)]
Move addYangPathArgument()

This method is only used for DataContainerCodecContext, there is just no
reason to pollute NodeCodecContext with this method. Reduces coupling
towards YangInstanceIdentifier.PathArgument a tiny bit.

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