X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=binding%2Fmdsal-binding-dom-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fbinding%2Fdom%2Fcodec%2Fimpl%2FDataObjectCodecContext.java;h=d99da25ddc04f21dd914376af14c9089ea26dcc5;hb=0032cbc207750ee84b76dfc395c29ade7adc76d4;hp=f076958cf33c1652e0161c21d59fcd563553ce89;hpb=fec64f6b8dcb6c2106c0328cc7f308a2493a32c9;p=mdsal.git diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecContext.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecContext.java index f076958cf3..d99da25ddc 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecContext.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecContext.java @@ -32,13 +32,12 @@ import org.opendaylight.mdsal.binding.model.api.GeneratedType; import org.opendaylight.mdsal.binding.model.api.Type; import org.opendaylight.mdsal.binding.runtime.api.AugmentRuntimeType; import org.opendaylight.mdsal.binding.runtime.api.AugmentableRuntimeType; -import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext; import org.opendaylight.mdsal.binding.runtime.api.CompositeRuntimeType; import org.opendaylight.yangtools.yang.binding.Augmentable; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.BindingObject; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.DataObjectStep; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -105,21 +104,22 @@ public abstract sealed class DataObjectCodecContext possibleAugmentations; + final var loader = prototype().contextFactory().getLoader(); if (Augmentable.class.isAssignableFrom(bindingClass)) { // Verify we have the appropriate backing runtimeType - final var runtimeType = prototype.getType(); + final var runtimeType = prototype.runtimeType(); if (!(runtimeType instanceof AugmentableRuntimeType augmentableRuntimeType)) { throw new VerifyException( "Unexpected type %s backing augmenable %s".formatted(runtimeType, bindingClass)); } possibleAugmentations = augmentableRuntimeType.augments(); - generatedClass = CodecDataObjectGenerator.generateAugmentable(factory().getLoader(), bindingClass, - analysis.leafContexts, analysis.daoProperties, keyMethod); + generatedClass = CodecDataObjectGenerator.generateAugmentable(loader, bindingClass, analysis.leafContexts, + analysis.daoProperties, keyMethod); } else { possibleAugmentations = List.of(); - generatedClass = CodecDataObjectGenerator.generate(factory().getLoader(), bindingClass, - analysis.leafContexts, analysis.daoProperties, keyMethod); + generatedClass = CodecDataObjectGenerator.generate(loader, bindingClass, analysis.leafContexts, + analysis.daoProperties, keyMethod); } // All done: acquire the constructor: it is supposed to be public @@ -134,11 +134,11 @@ public abstract sealed class DataObjectCodecContext>(); - final var augClassToProto = new HashMap, AugmentationCodecPrototype>(); + final var augClassToProto = new HashMap, AugmentationCodecPrototype>(); for (var augment : possibleAugmentations) { final var augProto = loadAugmentPrototype(augment); if (augProto != null) { - final var augBindingClass = augProto.getBindingClass(); + final var augBindingClass = augProto.javaClass(); for (var childPath : augProto.getChildArgs()) { augPathToBinding.putIfAbsent(childPath, augBindingClass); } @@ -150,13 +150,13 @@ public abstract sealed class DataObjectCodecContext pathChildPrototype(final Class argType) { + final DataContainerPrototype pathChildPrototype(final Class argType) { final var child = super.pathChildPrototype(argType); return child != null ? child : augmentToPrototype.get(argType); } @Override - final CommonDataObjectCodecPrototype streamChildPrototype(final Class childClass) { + final DataContainerPrototype streamChildPrototype(final Class childClass) { final var child = super.streamChildPrototype(childClass); if (child == null && Augmentation.class.isAssignableFrom(childClass)) { return getAugmentationProtoByClass(childClass); @@ -187,13 +187,13 @@ public abstract sealed class DataObjectCodecContext, AugmentationCodecPrototype>) MISMATCHED_AUGMENTED.getAcquire(this); + final var local = (ImmutableMap, AugmentationCodecPrototype>) MISMATCHED_AUGMENTED.getAcquire(this); final var mismatched = local.get(childClass); return mismatched != null ? mismatched : loadMismatchedAugmentation(local, childClass); } - private @Nullable AugmentationCodecPrototype loadMismatchedAugmentation( - final ImmutableMap, AugmentationCodecPrototype> oldMismatched, + private @Nullable AugmentationCodecPrototype loadMismatchedAugmentation( + final ImmutableMap, AugmentationCodecPrototype> oldMismatched, final @NonNull Class childClass) { @SuppressWarnings("rawtypes") final Class augTarget = findAugmentationTarget((Class) childClass); @@ -201,8 +201,8 @@ public abstract sealed class DataObjectCodecContext, AugmentationCodecPrototype> oldMismatched, - final @NonNull Class childClass, final @NonNull AugmentationCodecPrototype prototype) { + private @NonNull AugmentationCodecPrototype cacheMismatched( + final @NonNull ImmutableMap, AugmentationCodecPrototype> oldMismatched, + final @NonNull Class childClass, final @NonNull AugmentationCodecPrototype prototype) { var expected = oldMismatched; while (true) { final var newMismatched = @@ -222,7 +222,7 @@ public abstract sealed class DataObjectCodecContext, AugmentationCodecPrototype>) + final var witness = (ImmutableMap, AugmentationCodecPrototype>) MISMATCHED_AUGMENTED.compareAndExchangeRelease(this, expected, newMismatched); if (witness == expected) { LOG.trace("Cached mismatched augmentation {} -> {} in {}", childClass, prototype, this); @@ -239,7 +239,7 @@ public abstract sealed class DataObjectCodecContext cls) { - final BindingRuntimeContext ctx = factory().getRuntimeContext(); + final var ctx = prototype().contextFactory().getRuntimeContext(); final Class loaded; try { loaded = ctx.loadClass(Type.of(cls)); @@ -250,7 +250,7 @@ public abstract sealed class DataObjectCodecContext loadAugmentPrototype(final AugmentRuntimeType augment) { // FIXME: in face of deviations this code should be looking at declared view, i.e. all possibilities at augment // declaration site final var childPaths = augment.statement() @@ -262,7 +262,7 @@ public abstract sealed class DataObjectCodecContext> augClass; try { @@ -271,7 +271,7 @@ public abstract sealed class DataObjectCodecContext(augClass, augment, factory, childPaths); } @Override @@ -297,7 +297,7 @@ public abstract sealed class DataObjectCodecContext deserializePathArgument(final PathArgument arg) { checkArgument(getDomPathArgument().equals(arg)); return bindingArg(); } @Override - public PathArgument serializePathArgument(final InstanceIdentifier.PathArgument arg) { - checkArgument(bindingArg().equals(arg)); + public PathArgument serializePathArgument(final DataObjectStep step) { + checkArgument(bindingArg().equals(step)); return getDomPathArgument(); } @@ -342,4 +342,9 @@ public abstract sealed class DataObjectCodecContext