2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
10 import java.util.Optional;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.openflowplugin.api.OFConstants;
13 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
14 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
18 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
23 import org.opendaylight.yangtools.yang.common.Uint8;
25 public class SalToOfGeneralExtensionGroupingCase
26 extends ConvertorCase<GeneralExtensionGrouping, Action, ActionConvertorData> {
27 public SalToOfGeneralExtensionGroupingCase() {
28 super(GeneralExtensionGrouping.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
32 public Optional<Action> process(@NonNull final GeneralExtensionGrouping source, final ActionConvertorData data,
33 final ConvertorExecutor convertorExecutor) {
34 final Uint8 version = data.getVersion();
37 * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
38 * - we might need sessionContext as converter input
41 Extension extAction = source.getExtension();
42 ConverterExtensionKey<? extends ExtensionKey> key =
43 new ConverterExtensionKey<>(source.getExtensionKey(), version);
44 ConvertorToOFJava<Action> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
45 return convertor != null ? Optional.of(convertor.convert(extAction)) : Optional.empty();