2 * Copyright © 2016 Red Hat, Inc. and others.
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.genius.mdsalutil.actions;
10 import org.opendaylight.genius.mdsalutil.ActionInfo;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfMplsLabelCaseBuilder;
16 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.NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
25 * Action to move an NXM register.
27 public class ActionRegMove extends ActionInfo {
29 private final Class<? extends NxmNxReg> register;
30 private final int start;
31 private final int end;
33 public ActionRegMove(Class<? extends NxmNxReg> register, int start, int end) {
34 this(0, register, start, end);
37 public ActionRegMove(int actionKey, Class<? extends NxmNxReg> register, int start, int end) {
39 this.register = register;
45 public Action buildAction() {
46 return buildAction(getActionKey());
50 public Action buildAction(int newActionKey) {
51 Src src = new SrcBuilder()
52 .setSrcChoice(new SrcNxRegCaseBuilder().setNxReg(register).build())
57 Dst dst = new DstBuilder()
58 .setDstChoice(new DstOfMplsLabelCaseBuilder().setOfMplsLabel(true).build())
63 NxRegMoveBuilder nxRegMoveBuilder = new NxRegMoveBuilder().setSrc(src).setDst(dst);
64 return new ActionBuilder()
65 .setAction(new NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegMove(
66 nxRegMoveBuilder.build()).build())
67 .setKey(new ActionKey(newActionKey))
71 public Class<? extends NxmNxReg> getRegister() {
75 public int getStart() {
84 public boolean equals(Object other) {
88 if (other == null || getClass() != other.getClass()) {
91 if (!super.equals(other)) {
95 ActionRegMove that = (ActionRegMove) other;
97 if (start != that.start) {
100 if (end != that.end) {
103 return register != null ? register.equals(that.register) : that.register == null;
107 public int hashCode() {
108 int result = super.hashCode();
109 result = 31 * result + (register != null ? register.hashCode() : 0);
110 result = 31 * result + start;
111 result = 31 * result + end;
116 public String toString() {
117 return "ActionRegMove [register=" + register + ", start=" + start + ", end=" + end + ", getActionKey()="
118 + getActionKey() + "]";