Remove EncodeConstants.SIZE_OF_{BYTE,SHORT,INT,LONG}_IN_BYTES
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / action / OF10SetNwDstActionDeserializer.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.deserialization.action;
9
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.util.ByteBufUtils;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
17
18 /**
19  * OF10SetNwDstActionDeserializer.
20  *
21  * @author michal.polkorab
22  */
23 public class OF10SetNwDstActionDeserializer extends AbstractActionDeserializer {
24     @Override
25     public Action deserialize(final ByteBuf input) {
26         final ActionBuilder builder = new ActionBuilder();
27         input.skipBytes(2 * Short.BYTES);
28         SetNwDstCaseBuilder caseBuilder = new SetNwDstCaseBuilder();
29         SetNwDstActionBuilder actionBuilder = new SetNwDstActionBuilder();
30         actionBuilder.setIpAddress(ByteBufUtils.readIetfIpv4Address(input));
31         caseBuilder.setSetNwDstAction(actionBuilder.build());
32         builder.setActionChoice(caseBuilder.build());
33         return builder.build();
34     }
35
36     @Override
37     protected ActionChoice getType() {
38         return new SetNwDstCaseBuilder().build();
39     }
40 }