ffe274b3c7334e3d87e9cb7c43226effe4e1347b
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / util / ActionSerializerRegistryHelper.java
1 /*
2  * Copyright (c) 2013 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.openflowjava.protocol.impl.util;
9
10 import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer;
11 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
12 import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;
14
15 /**
16  * @author michal.polkorab
17  */
18 public class ActionSerializerRegistryHelper {
19
20     private short version;
21     private SerializerRegistry serializerRegistry;
22
23     /**
24      * @param version Openflow wire version
25      * @param objectType
26      * @param serializerRegistry
27      */
28     public ActionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) {
29         this.version = version;
30         this.serializerRegistry = serializerRegistry;
31     }
32
33     /**
34      * Registers given serializer
35      * @param actionType
36      * @param serializer
37      */
38     public <T extends ActionBase> void registerSerializer(Class<T> actionType,
39             OFGeneralSerializer serializer) {
40         serializerRegistry.registerSerializer(new ActionSerializerKey<>(version,
41                 actionType, null), serializer);
42     }
43 }