Bug 5540 - Remove ConvertorManager singleton
[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 java.util.Collection;
12 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
13 import org.opendaylight.yangtools.yang.binding.DataContainer;
14
15 /**
16  * Converts OpenflowJava to MDSal model and vice versa
17  *
18  * @param <FROM> type of source
19  * @param <TO>   type of result
20  * @param <DATA> the type parameter
21  */
22 public abstract class Convertor<FROM, TO, DATA extends ConvertorData> {
23     private ConvertorExecutor convertorExecutor;
24
25     /**
26      * Gets convertor manager.
27      *
28      * @return the convertor manager
29      */
30     protected ConvertorExecutor getConvertorExecutor() {
31         return convertorExecutor;
32     }
33
34     /**
35      * Sets convertor manager.
36      *
37      * @param convertorExecutor the convertor manager
38      */
39     public void setConvertorExecutor(ConvertorExecutor convertorExecutor) {
40         this.convertorExecutor = convertorExecutor;
41     }
42
43     /**
44      * Gets type of convertor, used in
45      * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager}.
46      *
47      * @return the type of convertor
48      */
49     public abstract Collection<Class<? extends DataContainer>> getTypes();
50
51     /**
52      * Converts source to result
53      *
54      * @param source source
55      * @param data   convertor data
56      * @return converted source
57      */
58     public abstract TO convert(FROM source, DATA data);
59 }