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 java.math.BigInteger;
11 import org.opendaylight.genius.mdsalutil.ActionInfo;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
17 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;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.Dst;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
23 * Action to load an NXM register.
25 public class ActionRegLoad extends ActionInfo {
27 private final Class<? extends NxmNxReg> register;
28 private final int start;
29 private final int end;
30 private final long load;
32 public ActionRegLoad(Class<? extends NxmNxReg> register, int start, int end, long load) {
33 this(0, register, start, end, load);
36 public ActionRegLoad(int actionKey, Class<? extends NxmNxReg> register, int start, int end, long load) {
38 this.register = register;
45 public Action buildAction() {
46 return buildAction(getActionKey());
50 public Action buildAction(int newActionKey) {
51 Dst dst = new DstBuilder().setDstChoice(new DstNxRegCaseBuilder().setNxReg(register).build())
55 NxRegLoadBuilder nxRegLoadBuilder = new NxRegLoadBuilder().setDst(dst).setValue(BigInteger.valueOf(load));
57 return new ActionBuilder()
58 .setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(
59 nxRegLoadBuilder.build()).build())
60 .setKey(new ActionKey(newActionKey))
64 public Class<? extends NxmNxReg> getRegister() {
68 public int getStart() {
76 public long getLoad() {
81 public boolean equals(Object other) {
85 if (other == null || getClass() != other.getClass()) {
88 if (!super.equals(other)) {
92 ActionRegLoad that = (ActionRegLoad) other;
94 if (start != that.start) {
97 if (end != that.end) {
100 if (load != that.load) {
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;
112 result = 31 * result + (int) (load ^ load >>> 32);
117 public String toString() {
118 return "ActionRegLoad [register=" + register + ", start=" + start + ", end=" + end + ", load=" + load
119 + ", getActionKey()=" + getActionKey() + "]";