BUG-8004: handle implicit RPC input
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / yangtools / binding / data / codec / impl / UnmappedRpcInputCodec.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.yangtools.binding.data.codec.impl;
9
10 import org.opendaylight.yangtools.yang.binding.DataObject;
11 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
12
13 /**
14  * Singleton codec for translating RPCs with implicit input statements, which are not mapped by binding spec v1. Since
15  * there is no equivalent, we always return null.
16  *
17  * @author Robert Varga
18  *
19  * @param <D> Data object type
20  */
21 final class UnmappedRpcInputCodec<D extends DataObject> implements RpcInputCodec<D> {
22     private static final UnmappedRpcInputCodec<?> INSTANCE = new UnmappedRpcInputCodec<>();
23
24     private UnmappedRpcInputCodec() {
25
26     }
27
28     @SuppressWarnings("unchecked")
29     static <D extends DataObject> UnmappedRpcInputCodec<D> getInstance() {
30         return (UnmappedRpcInputCodec<D>) INSTANCE;
31     }
32
33     @Override
34     public D deserialize(final NormalizedNode<?, ?> data) {
35         return null;
36     }
37
38     @Override
39     public NormalizedNode<?, ?> serialize(final D data) {
40         throw new UnsupportedOperationException("Serialization of " + data + " not supported");
41     }
42 }