2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
10 import static java.util.Objects.requireNonNull;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.binding.dom.codec.api.CommonDataObjectCodecTreeNode;
14 import org.opendaylight.mdsal.binding.runtime.api.RuntimeTypeContainer;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
17 import org.opendaylight.yangtools.yang.common.QNameModule;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
22 * Base implementation of {@link CommonDataObjectCodecTreeNode}.
24 abstract sealed class CommonDataObjectCodecContext<D extends DataObject, T extends RuntimeTypeContainer>
25 extends DataContainerCodecContext<D, T> implements CommonDataObjectCodecTreeNode<D>
26 permits AbstractDataObjectCodecContext, ChoiceCodecContext {
27 final @NonNull CommonDataObjectCodecPrototype<T> prototype;
29 CommonDataObjectCodecContext(final CommonDataObjectCodecPrototype<T> prototype) {
30 super(prototype.getType());
31 this.prototype = requireNonNull(prototype);
34 @SuppressWarnings("unchecked")
36 public final Class<D> getBindingClass() {
37 return Class.class.cast(prototype.getBindingClass());
41 protected final CodecContextFactory factory() {
42 return prototype.getFactory();
46 protected final T type() {
47 return prototype.getType();
51 protected NodeIdentifier getDomPathArgument() {
52 return prototype.getYangArg();
56 * Returns deserialized Binding Path Argument from YANG instance identifier.
58 protected PathArgument getBindingPathArgument(final YangInstanceIdentifier.PathArgument domArg) {
62 protected final PathArgument bindingArg() {
63 return prototype.getBindingArg();
66 protected final QNameModule namespace() {
67 return prototype.getNamespace();