c1bd1b85a65a2fcdc8f36110f0e054319392e592
[mdsal.git] / binding2 / mdsal-binding2-dom-codec / src / main / java / org / opendaylight / mdsal / binding / javav2 / dom / codec / impl / context / CaseNodeCodecContext.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies 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.javav2.dom.codec.impl.context;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import java.util.List;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base.DataContainerCodecPrototype;
15 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base.TreeNodeCodecContext;
16 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeArgument;
17 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
20 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
21 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
23
24 /**
25  * Codec context for serializing and deserializing choice case node and it's
26  * path.
27  *
28  * @param <D>
29  *            - type of tree node
30  */
31 @Beta
32 public final class CaseNodeCodecContext<D extends TreeNode> extends TreeNodeCodecContext<D, ChoiceCaseNode> {
33
34     /**
35      * Prepare context for choice case node from prototype.
36      *
37      * @param prototype
38      *            - codec prototype of choice case node
39      */
40     public CaseNodeCodecContext(final DataContainerCodecPrototype<ChoiceCaseNode> prototype) {
41         super(prototype);
42     }
43
44     @SuppressWarnings("rawtypes")
45     @Override
46     protected void addYangPathArgument(final TreeArgument arg, final List<PathArgument> builder) {
47         // add your implementation
48     }
49
50     @Nonnull
51     @Override
52     public D deserialize(@Nonnull final NormalizedNode<?, ?> normalizedNode) {
53         Preconditions.checkState(normalizedNode instanceof ChoiceNode);
54         return createBindingProxy((ChoiceNode) normalizedNode);
55     }
56
57     @Override
58     protected Object deserializeObject(final NormalizedNode<?, ?> normalizedNode) {
59         return deserialize(normalizedNode);
60     }
61
62     @SuppressWarnings("rawtypes")
63     @Override
64     public PathArgument serializePathArgument(final TreeArgument arg) {
65         Preconditions.checkArgument(arg == null);
66         return null;
67     }
68
69     @SuppressWarnings("rawtypes")
70     @Override
71     public TreeArgument deserializePathArgument(final YangInstanceIdentifier.PathArgument arg) {
72         Preconditions.checkArgument(arg == null);
73         return null;
74     }
75 }