Split out DataContainerCodecPrototype subclasses
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / AugmentationCodecPrototype.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 java.util.Objects.requireNonNull;
11
12 import com.google.common.collect.ImmutableSet;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.mdsal.binding.dom.codec.impl.NodeCodecContext.CodecContextFactory;
15 import org.opendaylight.mdsal.binding.runtime.api.AugmentRuntimeType;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
20
21 final class AugmentationCodecPrototype extends DataContainerCodecPrototype<AugmentRuntimeType> {
22     private final @NonNull ImmutableSet<NodeIdentifier> childArgs;
23
24     @SuppressWarnings("unchecked")
25     AugmentationCodecPrototype(final Class<?> cls, final QNameModule namespace, final AugmentRuntimeType type,
26             final CodecContextFactory factory, final ImmutableSet<NodeIdentifier> childArgs) {
27         super(Item.of((Class<? extends DataObject>) cls), namespace, type, factory);
28         this.childArgs = requireNonNull(childArgs);
29     }
30
31     @Override
32     NodeIdentifier getYangArg() {
33         throw new UnsupportedOperationException("Augmentation does not have PathArgument address");
34     }
35
36     @Override
37     AugmentationNodeContext<?> createInstance() {
38         return new AugmentationNodeContext<>(this);
39     }
40
41     // Guaranteed to be non-empty
42     @NonNull ImmutableSet<NodeIdentifier> getChildArgs() {
43         return childArgs;
44     }
45 }