6074b8fe2ea02ef5c87983352946048f6e551037
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / api / MessageTransformer.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.netconf.sal.connect.api;
9
10 import org.opendaylight.mdsal.dom.api.DOMActionResult;
11 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
12 import org.opendaylight.mdsal.dom.api.DOMNotification;
13 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
17
18 public interface MessageTransformer<M> {
19
20     DOMNotification toNotification(M message);
21
22     M toRpcRequest(QName rpc, NormalizedNode node);
23
24     DOMRpcResult toRpcResult(M message, QName rpc);
25
26     /**
27      * Parse action into message for request.
28      *
29      * @param action - action schema path
30      * @param domDataTreeIdentifier - identifier of action
31      * @param payload - input of action
32      * @return message
33      */
34     default M toActionRequest(final Absolute action, final DOMDataTreeIdentifier domDataTreeIdentifier,
35             final NormalizedNode payload) {
36         throw new UnsupportedOperationException();
37     }
38
39     /**
40      * Parse result of invoking action into DOM result.
41      *
42      * @param action - action schema path
43      * @param message - message to parsing
44      * @return {@link DOMActionResult}
45      */
46     default DOMActionResult toActionResult(final Absolute action, final M message) {
47         throw new UnsupportedOperationException();
48     }
49 }