c60cfccc372226abe4158d1715cac6ef610f3459
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / action / cases / SalToOfSetTpSrcActionV10Case.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
10
11 import java.util.Optional;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.openflowplugin.api.OFConstants;
14 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 public class SalToOfSetTpSrcActionV10Case extends ConvertorCase<SetTpSrcActionCase, Action, ActionConvertorData> {
28     private static final Logger LOG = LoggerFactory.getLogger(SalToOfSetTpSrcActionV10Case.class);
29
30     public SalToOfSetTpSrcActionV10Case() {
31         super(SetTpSrcActionCase.class, true, OFConstants.OFP_VERSION_1_0);
32     }
33
34     @Nonnull
35     @Override
36     public Optional<Action> process(@Nonnull final SetTpSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
37         SetTpSrcAction settpsrcaction = source.getSetTpSrcAction();
38         SetTpSrcCaseBuilder setTpSrcCaseBuilder = new SetTpSrcCaseBuilder();
39         SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
40         setTpSrcActionBuilder.setPort(new PortNumber(settpsrcaction.getPort()
41                 .getValue()
42                 .longValue()));
43         setTpSrcCaseBuilder.setSetTpSrcAction(setTpSrcActionBuilder.build());
44
45         return Optional.of(new ActionBuilder()
46                 .setActionChoice(setTpSrcCaseBuilder.build())
47                 .build());
48     }
49 }