Bug 5540 - ConvertorManager DataContainer source, one Convertor interface
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / common / Convertor.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
10
11 import javax.annotation.Nullable;
12 import org.opendaylight.yangtools.yang.binding.DataContainer;
13
14 /**
15  * Converts OpenflowJava to MDSal model and vice versa
16  *
17  * @param <FROM> type of source
18  * @param <TO>   type of result
19  */
20 public interface Convertor<FROM, TO, DATA extends ConvertorData> {
21
22     /**
23      * Gets type of convertor, used in
24      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager}.
25      *
26      * @return the type of convertor
27      */
28     Class<? extends DataContainer> getType();
29
30     /**
31      * Converts source to result
32      *
33      * @param source source
34      * @param data   convertor data
35      * @return converted source
36      */
37     TO convert(FROM source, @Nullable DATA data);
38 }