92936436a0dc30ec1df4da2b8a286907777441b1
[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  * @param <D>
25  *            - type of tree node
26  */
27 @Beta
28 public final class AugmentationNodeContext<D extends TreeNode & Augmentation<?>>
29         extends TreeNodeCodecContext<D, AugmentationSchema> {
30
31     /**
32      * Prepare context for augmentation node from prototype.
33      *
34      * @param prototype
35      *            - codec prototype of augmentation node
36      */
37     public AugmentationNodeContext(final DataContainerCodecPrototype<AugmentationSchema> prototype) {
38         super(prototype);
39     }
40
41     @Nonnull
42     @Override
43     public D deserialize(@Nonnull final NormalizedNode<?, ?> normalizedNode) {
44         Preconditions.checkArgument(normalizedNode instanceof AugmentationNode);
45         return createBindingProxy((AugmentationNode) normalizedNode);
46     }
47
48     @Override
49     protected Object deserializeObject(final NormalizedNode<?, ?> normalizedNode) {
50         return deserialize(normalizedNode);
51     }
52 }