Update MRI upstreams for Phosphorus
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / action / cases / OfToSalSetTpSrcCase.java
1 /*
2  * Copyright (c) 2017 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
9
10 import java.util.Optional;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.openflowplugin.api.OFConstants;
13 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
14 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCase;
21
22 public class OfToSalSetTpSrcCase extends ConvertorCase<SetTpSrcCase, Action, ActionResponseConvertorData> {
23     public OfToSalSetTpSrcCase() {
24         super(SetTpSrcCase.class, true, OFConstants.OFP_VERSION_1_0);
25     }
26
27     @Override
28     public Optional<Action> process(@NonNull final SetTpSrcCase source, final ActionResponseConvertorData data,
29             final ConvertorExecutor convertorExecutor) {
30         return Optional.of(new SetTpSrcActionCaseBuilder()
31                 .setSetTpSrcAction(new SetTpSrcActionBuilder()
32                         .setPort(new PortNumber(source.getSetTpSrcAction().getPort().getValue().toUint16()))
33                         .setIpProtocol(data.getIpProtocol())
34                         .build())
35                 .build());
36     }
37 }