f89fd0a1a6d853c9c8c8dfc97c4464b1213b43bc
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / util / InstructionSerializerRegistryHelper.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.InstructionSerializerKey;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
14
15 /**
16  * @author michal.polkorab
17  */
18 public class InstructionSerializerRegistryHelper {
19
20     private short version;
21     private SerializerRegistry serializerRegistry;
22
23     /**
24      * @param version Openflow wire version
25      * @param serializerRegistry
26      */
27     public InstructionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) {
28         this.version = version;
29         this.serializerRegistry = serializerRegistry;
30     }
31
32     /**
33      * Registers given serializer
34      * @param instructionType 
35      * @param serializer
36      */
37     public <TYPE extends InstructionBase> void registerSerializer(Class<TYPE> instructionType,
38             OFGeneralSerializer serializer) {
39         serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version,
40                 instructionType, null), serializer);
41     }
42 }