/* * Copyright (c) 2016 Red Hat, 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.genius.mdsalutil.actions; import java.math.BigInteger; import org.opendaylight.genius.mdsalutil.ActionInfo; import org.opendaylight.genius.mdsalutil.ActionType; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxOfInPortCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder; /** * NX load in port action. */ public class ActionNxLoadInPort extends ActionInfo { private final BigInteger value; public ActionNxLoadInPort(BigInteger value) { this(0, value); } public ActionNxLoadInPort(int actionKey, BigInteger value) { super(ActionType.nx_load_in_port, new BigInteger[] {value}, actionKey); this.value = value; } @Deprecated public ActionNxLoadInPort(ActionInfo actionInfo) { this(actionInfo.getActionKey(), actionInfo.getBigActionValues()[0]); } @Override public Action buildAction() { return buildAction(getActionKey()); } public Action buildAction(int newActionKey) { return new ActionBuilder() .setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder() .setNxRegLoad(new NxRegLoadBuilder() .setDst(new DstBuilder() .setDstChoice(new DstNxOfInPortCaseBuilder().setOfInPort(true).build()) .setStart(0) .setEnd(15) .build()) .setValue(value) .build()) .build()) .setKey(new ActionKey(newActionKey)) .build(); } public BigInteger getValue() { return value; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; ActionNxLoadInPort that = (ActionNxLoadInPort) o; return value != null ? value.equals(that.value) : that.value == null; } @Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (value != null ? value.hashCode() : 0); return result; } }