/*
* Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases;
import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
public class SalToOfSetNwTosActionV10Case extends ConvertorCase<SetNwTosActionCase, Action, ActionConvertorData> {
public SalToOfSetNwTosActionV10Case() {
super(SetNwTosActionCase.class, true, OFConstants.OFP_VERSION_1_0);
}
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwTosActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
SetNwTosAction setnwtosaction = source.getSetNwTosAction();
SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
SetNwTosCaseBuilder setNwTosCaseBuilder = new SetNwTosCaseBuilder();
setNwTosActionBuilder.setNwTos(setnwtosaction.getTos().shortValue());
setNwTosCaseBuilder.setSetNwTosAction(setNwTosActionBuilder.build());
return Optional.of(new ActionBuilder()
.setActionChoice(setNwTosCaseBuilder.build())
.build());
}
}