Merge "JUnit test case for ITM"
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / ActionInfo.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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;
9
10 import com.google.common.base.MoreObjects;
11 import java.io.Serializable;
12 import java.math.BigInteger;
13 import java.util.Arrays;
14
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
16
17 public class ActionInfo implements Serializable {
18
19     private static final long serialVersionUID = 1L;
20
21     private final ActionType m_actionType;
22
23     private String[] m_asActionValues = null;
24     private BigInteger[] m_aBigIntValues;
25     private int m_actionKey = 0;
26
27     public ActionInfo(ActionInfo action) {
28         super();
29         m_actionType = action.m_actionType;
30         m_actionKey = action.m_actionKey;
31         m_asActionValues = Arrays.copyOf(action.m_asActionValues, action.m_asActionValues.length);
32     }
33
34     public ActionInfo(ActionType actionType, String[] asActionValues) {
35         m_actionType = actionType;
36         m_actionKey = 0;
37         m_asActionValues = asActionValues;
38     }
39
40     public ActionInfo(ActionType actionType, String[] asActionValues, int actionKey) {
41         m_actionType = actionType;
42         m_actionKey = actionKey;
43         m_asActionValues = asActionValues;
44     }
45
46     public ActionInfo(ActionType actionType, BigInteger[] aBigIntValues) {
47         m_actionType = actionType;
48         m_actionKey = 0;
49         m_aBigIntValues = aBigIntValues;
50     }
51
52     public ActionInfo(ActionType actionType, BigInteger[] aBigIntValues, int actionKey) {
53         m_actionType = actionType;
54         m_actionKey = actionKey;
55         m_aBigIntValues = aBigIntValues;
56     }
57
58     public void setActionKey(int key) {
59         m_actionKey = key;
60     }
61
62     public int getActionKey() {
63         return m_actionKey;
64     }
65
66     public Action buildAction() {
67         return m_actionType.buildAction(this);
68     }
69
70     public ActionType getActionType() {
71         return m_actionType;
72     }
73
74     public String[] getActionValues() {
75         return m_asActionValues;
76     }
77
78     public BigInteger[] getBigActionValues() {
79         return m_aBigIntValues;
80     }
81
82     @Override
83     public String toString() {
84         return MoreObjects.toStringHelper(this).omitNullValues().add("actionType", m_actionType)
85                 .add("actionValues", Arrays.deepToString(m_asActionValues))
86                 .add("bigActionValues", Arrays.deepToString(m_aBigIntValues))
87                 .add("actionKey", m_actionKey).toString();
88     }
89 }