Separate out DataContainerPrototype
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / MapCodecPrototype.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 com.google.common.base.Preconditions.checkArgument;
11
12 import org.opendaylight.mdsal.binding.runtime.api.ListRuntimeType;
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
14 import org.opendaylight.yangtools.yang.binding.KeyAware;
15
16 /**
17  * A prototype for a {@link MapCodecContext}.
18  */
19 final class MapCodecPrototype extends ListCodecPrototype {
20     MapCodecPrototype(final Item<?> item, final ListRuntimeType type, final CodecContextFactory factory) {
21         super(item, type, factory);
22         final var clazz = javaClass();
23         checkArgument(KeyAware.class.isAssignableFrom(clazz), "%s is not KeyAware", clazz);
24     }
25
26     @Override
27     ListCodecContext<?> createInstance() {
28         return MapCodecContext.of(this);
29     }
30 }