2 * Copyright (c) 2024 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.runtime.api.CompositeRuntimeType;
14 import org.opendaylight.yangtools.yang.binding.DataContainer;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
18 * A prototype for codecs dealing with {@link DataContainer}s.
20 * @param <C> {@link CodecContext} type
21 * @param <R> {@link CompositeRuntimeType} type
23 abstract sealed class DataContainerPrototype<C extends DataContainerCodecContext<?, R, ?>,
24 R extends CompositeRuntimeType>
25 extends LazyCodecContextSupplier<C> permits ChoiceCodecPrototype, CommonDataObjectCodecPrototype {
26 private final @NonNull CodecContextFactory contextFactory;
27 private final @NonNull R runtimeType;
29 DataContainerPrototype(final CodecContextFactory contextFactory, final R runtimeType) {
30 this.contextFactory = requireNonNull(contextFactory);
31 this.runtimeType = requireNonNull(runtimeType);
35 * Return the {@link CodecContextFactory} associated with this prototype.
37 * @return the context factory associated with this prototype
39 final @NonNull CodecContextFactory contextFactory() {
40 return contextFactory;
44 * Return associated run-time type.
46 * @return associated run-time type
48 final @NonNull R runtimeType() {
53 * Return the generated binding class this prototype corresponds to.
55 * @return the generated binding class this prototype corresponds to
57 abstract @NonNull Class<? extends DataContainer> javaClass();
59 abstract @NonNull NodeIdentifier yangArg();