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%2FDataObjectCodecPrototype.java;h=e53354f09d2618902efa030cd997742c3ea8c9b3;hb=f3be50ed801e5de305eb46b824e6bc3c6075e4bc;hp=964f0296f82727b3badb77d9f73890aeb64b1846;hpb=2b6ec88b72b016355edccd499e3177629b19e6d9;p=mdsal.git diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecPrototype.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecPrototype.java index 964f0296f8..e53354f09d 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecPrototype.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecPrototype.java @@ -10,21 +10,17 @@ package org.opendaylight.mdsal.binding.dom.codec.impl; import static java.util.Objects.requireNonNull; import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.mdsal.binding.runtime.api.ChoiceRuntimeType; -import org.opendaylight.mdsal.binding.runtime.api.ContainerLikeRuntimeType; -import org.opendaylight.mdsal.binding.runtime.api.ContainerRuntimeType; -import org.opendaylight.mdsal.binding.runtime.api.ListRuntimeType; -import org.opendaylight.mdsal.binding.runtime.api.RuntimeTypeContainer; +import org.opendaylight.mdsal.binding.runtime.api.CompositeRuntimeType; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item; -import org.opendaylight.yangtools.yang.binding.KeyAware; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.model.api.stmt.PresenceEffectiveStatement; -// FIXME: abstract and sealed -non-sealed class DataObjectCodecPrototype extends DataContainerCodecPrototype { +abstract sealed class DataObjectCodecPrototype extends CommonDataObjectCodecPrototype + permits CaseCodecPrototype, ContainerLikeCodecPrototype, ListCodecPrototype, + NotificationCodecContext.Prototype { private final @NonNull NodeIdentifier yangArg; + // FIXME: this should not be needed @SuppressWarnings("unchecked") DataObjectCodecPrototype(final Class cls, final NodeIdentifier yangArg, final T type, final CodecContextFactory factory) { @@ -33,33 +29,12 @@ non-sealed class DataObjectCodecPrototype extend DataObjectCodecPrototype(final Item bindingArg, final NodeIdentifier yangArg, final T type, final CodecContextFactory factory) { - super(bindingArg, yangArg.getNodeType().getModule(), type, factory); + super(bindingArg, type, factory); this.yangArg = requireNonNull(yangArg); } @Override - final NodeIdentifier getYangArg() { + final NodeIdentifier yangArg() { return yangArg; } - - @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - DataContainerCodecContext createInstance() { - final var type = getType(); - if (type instanceof ContainerLikeRuntimeType containerLike) { - if (containerLike instanceof ContainerRuntimeType container - && container.statement().findFirstEffectiveSubstatement(PresenceEffectiveStatement.class) - .isEmpty()) { - return new StructuralContainerCodecContext(this); - } - return new ContainerNodeCodecContext(this); - } else if (type instanceof ListRuntimeType) { - return KeyAware.class.isAssignableFrom(getBindingClass()) - ? KeyedListNodeCodecContext.create((DataContainerCodecPrototype) this) - : new ListNodeCodecContext(this); - } else if (type instanceof ChoiceRuntimeType) { - return new ChoiceCodecContext(this); - } - throw new IllegalArgumentException("Unsupported type " + getBindingClass() + " " + type); - } -} \ No newline at end of file +}