Merge remote-tracking branch 'liblldp/master'
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / action / cases / SalToOfSetQueueActionCase.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.SetQueueActionCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueActionBuilder;
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
24 public class SalToOfSetQueueActionCase extends ConvertorCase<SetQueueActionCase, Action, ActionConvertorData> {
25     public SalToOfSetQueueActionCase() {
26         super(SetQueueActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
27     }
28
29     @Nonnull
30     @Override
31     public Optional<Action> process(@Nonnull final SetQueueActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
32         SetQueueAction setQueueAction = source.getSetQueueAction();
33         SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
34         SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
35         setQueueBuilder.setQueueId(setQueueAction.getQueueId());
36         setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
37
38         return Optional.of(new ActionBuilder()
39                 .setActionChoice(setQueueCaseBuilder.build())
40                 .build());
41     }
42 }