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.CompositeRuntimeType;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
21 * Base implementation of {@link CommonDataObjectCodecTreeNode}.
23 abstract sealed class CommonDataObjectCodecContext<D extends DataObject, T extends CompositeRuntimeType>
24 extends DataContainerCodecContext<D, T> implements CommonDataObjectCodecTreeNode<D>
25 permits AbstractDataObjectCodecContext, ChoiceCodecContext {
26 final @NonNull CommonDataObjectCodecPrototype<T> prototype;
28 CommonDataObjectCodecContext(final CommonDataObjectCodecPrototype<T> prototype) {
29 super(prototype.getType());
30 this.prototype = requireNonNull(prototype);
33 @SuppressWarnings("unchecked")
35 public final Class<D> getBindingClass() {
36 return Class.class.cast(prototype.getBindingClass());
40 protected final CodecContextFactory factory() {
41 return prototype.getFactory();
45 protected final T type() {
46 return prototype.getType();
50 protected NodeIdentifier getDomPathArgument() {
51 return prototype.getYangArg();
55 * Returns deserialized Binding Path Argument from YANG instance identifier.
57 protected PathArgument getBindingPathArgument(final YangInstanceIdentifier.PathArgument domArg) {
61 protected final PathArgument bindingArg() {
62 return prototype.getBindingArg();