OPNFLWPLUG-1071 : Removal of javax.annotation.Nonnnull and replacement of javax.annot...
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / action / cases / SalToOfSetNwTtlActionCase.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 org.eclipse.jdt.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.SetNwTtlActionCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
22
23 public class SalToOfSetNwTtlActionCase extends ConvertorCase<SetNwTtlActionCase, Action, ActionConvertorData> {
24     public SalToOfSetNwTtlActionCase() {
25         super(SetNwTtlActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
26     }
27
28     @NonNull
29     @Override
30     public Optional<Action> process(@NonNull final SetNwTtlActionCase source, final ActionConvertorData data,
31             ConvertorExecutor convertorExecutor) {
32         SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
33         SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
34         nwTtlBuilder.setNwTtl(source.getSetNwTtlAction().getNwTtl());
35         nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
36
37         return Optional.of(new ActionBuilder()
38                 .setActionChoice(nwTtlCaseBuilder.build())
39                 .build());
40     }
41 }