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