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
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
11 import java.util.Optional;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.openflowplugin.api.OFConstants;
14 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
15 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
16 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
18 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
19 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class SalToOfVendorCodecCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action, ActionConvertorData> {
25 private static final Logger LOG = LoggerFactory.getLogger(SalToOfVendorCodecCase.class);
27 public SalToOfVendorCodecCase() {
28 super(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
31 @SuppressWarnings("unchecked")
34 public Optional<Action> process(@Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action source, final ActionConvertorData data) {
35 final short version = data.getVersion();
36 final TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
38 (Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) source.getImplementedInterface(),
41 ExtensionConverterProvider extensionConverterProvider = OFSessionUtil.getExtensionConvertorProvider();
43 if (extensionConverterProvider == null) {
44 return Optional.empty();
47 final ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor =
48 extensionConverterProvider.getConverter(key);
50 LOG.trace("OFP Extension action, key:{}, converter:{}", key, convertor);
51 return convertor != null ? Optional.of(convertor.convert(source)) : Optional.empty();