Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / openflowjava / openflowjava-util / src / main / java / org / opendaylight / openflowjava / util / ExperimenterSerializerKeyFactory.java
1 /*
2  * Copyright (c) 2014 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.util;
9
10 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey;
11 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey;
12 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
17 import org.opendaylight.yangtools.yang.common.Uint32;
18 import org.opendaylight.yangtools.yang.common.Uint8;
19
20 /**
21  * Factory for creating experimenter serializer keys.
22  *
23  * @author michal.polkorab
24  */
25 public abstract class ExperimenterSerializerKeyFactory {
26
27     /**
28      * Creates an experimenter message serializer key.
29      *
30      * @param msgVersion openflow wire version
31      * @param experimenterId experimenter / vendor ID
32      * @param type experimenter type according to vendor implementation
33      * @return key instance
34      */
35     public static ExperimenterIdSerializerKey<ExperimenterDataOfChoice> createExperimenterMessageSerializerKey(
36             final Uint8 msgVersion, final Uint32 experimenterId, final long type) {
37         return new ExperimenterIdTypeSerializerKey<>(msgVersion, experimenterId, type, ExperimenterDataOfChoice.class);
38     }
39
40     /**
41      * Creates a multi-part request serializer key.
42      *
43      * @param msgVersion openflow wire version
44      * @param experimenterId experimenter / vendor ID
45      * @param type experimenter type according to vendor implementation
46      * @return key instance
47      */
48     public static ExperimenterIdSerializerKey<ExperimenterDataOfChoice> createMultipartRequestSerializerKey(
49             final Uint8 msgVersion, final Uint32 experimenterId, final long type) {
50         return new ExperimenterIdTypeSerializerKey<>(msgVersion, experimenterId, type, ExperimenterDataOfChoice.class);
51     }
52
53     /**
54      * Creates a multi-part request TF serializer key.
55      *
56      * @param msgVersion openflow wire version
57      * @param experimenterId experimenter / vendor ID
58      * @return key instance
59      */
60     public static ExperimenterIdSerializerKey<TableFeatureProperties> createMultipartRequestTFSerializerKey(
61             final Uint8 msgVersion, final Uint32 experimenterId) {
62         return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, TableFeatureProperties.class);
63     }
64
65     /**
66      * Creates a meter band serializer key.
67      *
68      * @param msgVersion openflow wire version
69      * @param experimenterId experimenter / vendor ID
70      * @return key instance
71      */
72     public static ExperimenterIdSerializerKey<MeterBandExperimenterCase> createMeterBandSerializerKey(
73             final Uint8 msgVersion, final Uint32 experimenterId) {
74         return new ExperimenterIdMeterSubTypeSerializerKey<>(msgVersion, experimenterId,
75                 MeterBandExperimenterCase.class, null);
76     }
77
78     public static ExperimenterIdSerializerKey<MeterBandExperimenterCase> createMeterBandSerializerKey(
79             final Uint8 msgVersion, final Uint32 experimenterId,
80             final ExperimenterMeterBandSubType meterSubType) {
81         return new ExperimenterIdMeterSubTypeSerializerKey<>(msgVersion, experimenterId,
82                 MeterBandExperimenterCase.class, meterSubType);
83     }
84 }