Reparent ChoiceCodecContext
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / DataObjectCodecPrototype.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.binding.runtime.api.CompositeRuntimeType;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
17
18 abstract sealed class DataObjectCodecPrototype<T extends CompositeRuntimeType> extends CommonDataObjectCodecPrototype<T>
19         permits CaseCodecPrototype, ContainerLikeCodecPrototype, ListCodecPrototype,
20                 NotificationCodecContext.Prototype {
21     private final @NonNull NodeIdentifier yangArg;
22
23     // FIXME: this should not be needed
24     @SuppressWarnings("unchecked")
25     DataObjectCodecPrototype(final Class<?> cls, final NodeIdentifier yangArg, final T type,
26             final CodecContextFactory factory) {
27         this(Item.of((Class<? extends DataObject>) cls), yangArg, type, factory);
28     }
29
30     DataObjectCodecPrototype(final Item<?> bindingArg, final NodeIdentifier yangArg, final T type,
31             final CodecContextFactory factory) {
32         super(bindingArg, type, factory);
33         this.yangArg = requireNonNull(yangArg);
34     }
35
36     @Override
37     final NodeIdentifier yangArg() {
38         return yangArg;
39     }
40 }