b906ff3f2569dd35575f42b41d94127dc6451ac1
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / ContainerLikeCodecContext.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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 org.opendaylight.mdsal.binding.runtime.api.ContainerLikeRuntimeType;
11 import org.opendaylight.yangtools.yang.binding.DataObject;
12 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
13 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15
16 sealed class ContainerLikeCodecContext<D extends DataObject>
17         extends DataObjectCodecContext<D, ContainerLikeRuntimeType<?, ?>> implements RpcInputCodec<D>
18         permits StructuralContainerCodecContext {
19     ContainerLikeCodecContext(final Class<D> cls, final ContainerLikeRuntimeType<?, ?> type,
20             final CodecContextFactory factory) {
21         this(new ContainerLikeCodecPrototype(Item.of(cls), type, factory));
22     }
23
24     ContainerLikeCodecContext(final ContainerLikeCodecPrototype prototype) {
25         super(prototype);
26     }
27
28     @Override
29     public final D deserialize(final NormalizedNode data) {
30         return createBindingProxy(checkDataArgument(ContainerNode.class, data));
31     }
32
33     @Override
34     protected final Object deserializeObject(final NormalizedNode normalizedNode) {
35         return deserialize(normalizedNode);
36     }
37 }