Add methods for modifying deserializer mapping
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / util / TypeToClassInitHelper.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 java.util.Map;
11 import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey;
12
13 /**
14  * @author michal.polkorab
15  *
16  */
17 public class TypeToClassInitHelper {
18
19     private short version;
20     private Map<TypeToClassKey, Class<?>> messageClassMap;
21
22     /**
23      * Constructor
24      * @param version protocol wire version
25      * @param messageClassMap map which stores type to class mapping
26      */
27     public TypeToClassInitHelper(short version, Map<TypeToClassKey,
28             Class<?>> messageClassMap) {
29         this.version = version;
30         this.messageClassMap = messageClassMap;
31     }
32
33     /**
34      * Registers Class int the type to class mapping
35      * @param type code value for message type / class
36      * @param clazz class corresponding to the code
37      */
38     public void registerTypeToClass(short type, Class<?> clazz) {
39         messageClassMap.put(new TypeToClassKey(version, type), clazz);
40     }
41 }