Reparent ChoiceCodecContext
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / CommonDataObjectCodecPrototype.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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
17 /**
18  * Common superclass for {@link DataObjectCodecPrototype} and {@link AugmentationCodecPrototype}.
19  *
20  * @param <R> {@link CompositeRuntimeType} type
21  */
22 abstract sealed class CommonDataObjectCodecPrototype<R extends CompositeRuntimeType>
23         extends DataContainerPrototype<CommonDataObjectCodecContext<?, R>, R>
24         permits AugmentationCodecPrototype, DataObjectCodecPrototype {
25     private final @NonNull Item<?> bindingArg;
26
27     CommonDataObjectCodecPrototype(final Item<?> bindingArg, final R runtimeType, final CodecContextFactory factory) {
28         super(factory, runtimeType);
29         this.bindingArg = requireNonNull(bindingArg);
30     }
31
32     @Override
33     final Class<? extends DataObject> javaClass() {
34         return bindingArg.getType();
35     }
36
37     final @NonNull Item<?> getBindingArg() {
38         return bindingArg;
39     }
40 }