Binding2 runtime - Codecs impl - context - part2
[mdsal.git] / binding2 / mdsal-binding2-dom-codec / src / main / java / org / opendaylight / mdsal / binding / javav2 / dom / codec / impl / context / AugmentationNodeContext.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 javax.annotation.Nonnull;
13 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base.DataContainerCodecPrototype;
14 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base.TreeNodeCodecContext;
15 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
16 import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentation;
17 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
20
21 /**
22  * Context for prototype of augmentation node.
23  */
24 @Beta
25 public final class AugmentationNodeContext<D extends TreeNode & Augmentation<?>>
26         extends TreeNodeCodecContext<D, AugmentationSchema> {
27
28     /**
29      * Prepare context for augmentation node from prototype.
30      *
31      * @param prototype
32      *            - codec prototype of augmentation node
33      */
34     public AugmentationNodeContext(final DataContainerCodecPrototype<AugmentationSchema> prototype) {
35         super(prototype);
36     }
37
38     @Nonnull
39     @Override
40     public D deserialize(@Nonnull final NormalizedNode<?, ?> normalizedNode) {
41         Preconditions.checkArgument(normalizedNode instanceof AugmentationNode);
42         return createBindingProxy((AugmentationNode) normalizedNode);
43     }
44
45     @Override
46     protected Object deserializeObject(final NormalizedNode<?, ?> normalizedNode) {
47         return deserialize(normalizedNode);
48     }
49 }