Bump mdsal to 4.0.0
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / actions / ActionNxLoadInPort.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.genius.mdsalutil.actions;
9
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.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxOfInPortCaseBuilder;
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.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
19 import org.opendaylight.yangtools.yang.common.Empty;
20
21 /**
22  * NX load in port action.
23  */
24 public class ActionNxLoadInPort extends ActionInfo {
25
26     private final BigInteger value;
27
28     public ActionNxLoadInPort(BigInteger value) {
29         this(0, value);
30     }
31
32     public ActionNxLoadInPort(int actionKey, BigInteger value) {
33         super(actionKey);
34         this.value = value;
35     }
36
37     @Override
38     public Action buildAction() {
39         return buildAction(getActionKey());
40     }
41
42     @Override
43     public Action buildAction(int newActionKey) {
44         return new ActionBuilder()
45             .setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder()
46                 .setNxRegLoad(new NxRegLoadBuilder()
47                     .setDst(new DstBuilder()
48                         .setDstChoice(new DstNxOfInPortCaseBuilder().setOfInPort(Empty.getInstance()).build())
49                         .setStart(0)
50                         .setEnd(15)
51                         .build())
52                     .setValue(value)
53                     .build())
54                 .build())
55             .withKey(new ActionKey(newActionKey))
56             .build();
57     }
58
59     public BigInteger getValue() {
60         return value;
61     }
62
63     @Override
64     public boolean equals(Object other) {
65         if (this == other) {
66             return true;
67         }
68         if (other == null || getClass() != other.getClass()) {
69             return false;
70         }
71         if (!super.equals(other)) {
72             return false;
73         }
74
75         ActionNxLoadInPort that = (ActionNxLoadInPort) other;
76
77         return value != null ? value.equals(that.value) : that.value == null;
78     }
79
80     @Override
81     public int hashCode() {
82         int result = super.hashCode();
83         result = 31 * result + (value != null ? value.hashCode() : 0);
84         return result;
85     }
86
87     @Override
88     public String toString() {
89         return "ActionNxLoadInPort [value=" + value + ", getActionKey()=" + getActionKey() + "]";
90     }
91
92 }