49b863b0061b43ca258ba98311c0a6cb065ccaf0
[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 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
17
18 /**
19  * Common superclass for {@link DataObjectCodecPrototype} and {@link AugmentationCodecPrototype}.
20  *
21  * @param <R> {@link CompositeRuntimeType} type
22  */
23 abstract sealed class CommonDataObjectCodecPrototype<R extends CompositeRuntimeType>
24         extends DataContainerPrototype<CommonDataObjectCodecContext<?, R>, R>
25         permits AugmentationCodecPrototype, DataObjectCodecPrototype {
26     private final @NonNull Item<?> bindingArg;
27
28     CommonDataObjectCodecPrototype(final Item<?> bindingArg, final R runtimeType, final CodecContextFactory factory) {
29         super(factory, runtimeType);
30         this.bindingArg = requireNonNull(bindingArg);
31     }
32
33     @Override
34     final Class<? extends DataObject> javaClass() {
35         return bindingArg.getType();
36     }
37
38     final @NonNull Item<?> getBindingArg() {
39         return bindingArg;
40     }
41
42     abstract @NonNull NodeIdentifier getYangArg();
43 }