Hide CodecContextSupplier
[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.InstanceIdentifier.Item;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
16
17 abstract sealed class CommonDataObjectCodecPrototype<T extends CompositeRuntimeType>
18         extends LazyCodecContextSupplier<CommonDataObjectCodecContext<?, T>>
19         permits AugmentationCodecPrototype, DataObjectCodecPrototype {
20     private final @NonNull T type;
21     private final @NonNull CodecContextFactory factory;
22     private final @NonNull Item<?> bindingArg;
23
24     CommonDataObjectCodecPrototype(final Item<?> bindingArg, final T type, final CodecContextFactory factory) {
25         this.bindingArg = requireNonNull(bindingArg);
26         this.type = requireNonNull(type);
27         this.factory = requireNonNull(factory);
28     }
29
30     final @NonNull T getType() {
31         return type;
32     }
33
34     final @NonNull CodecContextFactory getFactory() {
35         return factory;
36     }
37
38     final @NonNull Class<?> getBindingClass() {
39         return bindingArg.getType();
40     }
41
42     final @NonNull Item<?> getBindingArg() {
43         return bindingArg;
44     }
45
46     abstract @NonNull NodeIdentifier getYangArg();
47 }