Rename opendaylight.mdsal.binding.runtime.api
[yangtools.git] / binding / binding-data-codec-dynamic / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / CaseCodecContext.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 java.util.List;
11 import org.opendaylight.yangtools.binding.runtime.api.CaseRuntimeType;
12 import org.opendaylight.yangtools.binding.lib.ChoiceIn;
13 import org.opendaylight.yangtools.binding.lib.DataObject;
14 import org.opendaylight.yangtools.binding.lib.DataObjectStep;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
16 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18
19 final class CaseCodecContext<C extends ChoiceIn<?> & DataObject> extends DataObjectCodecContext<C, CaseRuntimeType> {
20     CaseCodecContext(final CaseCodecPrototype<C> prototype) {
21         super(prototype, prototype.javaClass());
22     }
23
24     @Override
25     void addYangPathArgument(final List<PathArgument> builder, final DataObjectStep<?> step) {
26         // NOOP
27     }
28
29     @Override
30     public C deserialize(final NormalizedNode data) {
31         return createBindingProxy(checkDataArgument(ChoiceNode.class, data));
32     }
33
34     @Override
35     public PathArgument serializePathArgument(final DataObjectStep<?> step) {
36         if (step != null) {
37             throw new IllegalArgumentException("Unexpected argument " + step);
38         }
39         return null;
40     }
41
42     @Override
43     public DataObjectStep<?> deserializePathArgument(final PathArgument arg) {
44         if (arg != null) {
45             throw new IllegalArgumentException("Unexpected argument " + arg);
46         }
47         return null;
48     }
49 }