Integration test, SimpleClient bundle
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / GetConfigReplyMessageFactory.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
2 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
3
4 import io.netty.buffer.ByteBuf;
5
6 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
10
11 /**
12  * @author michal.polkorab
13  * @author timotej.kubas
14  */
15 public class GetConfigReplyMessageFactory implements OFDeserializer<GetConfigOutput> {
16
17     private static GetConfigReplyMessageFactory instance;
18     
19     private GetConfigReplyMessageFactory() {
20         // singleton
21     }
22     
23     /**
24      * @return singleton factory
25      */
26     public static synchronized GetConfigReplyMessageFactory getInstance(){
27         if(instance == null){
28             instance = new GetConfigReplyMessageFactory();
29         }
30         return instance;
31     }
32
33     @Override
34     public GetConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
35         GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
36         builder.setVersion(version);
37         builder.setXid(rawMessage.readUnsignedInt());
38         builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
39         builder.setMissSendLen(rawMessage.readUnsignedShort());
40         return builder.build();
41     }
42 }