Merge "Added threadpool config tests."
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / core / Actions.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.core;
11
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlElement;
15 import javax.xml.bind.annotation.XmlRootElement;
16
17 /**
18  * @file   Actions.java
19  *
20  * @brief  Class representing actions
21  *
22  * Describes supported actions
23  */
24
25 @XmlRootElement
26 @XmlAccessorType(XmlAccessType.NONE)
27 public class Actions extends Property {
28         private static final long serialVersionUID = 1L;
29     @XmlElement(name="value")
30     private int actionsValue;
31
32     public enum ActionType {
33         OUTPUT_PORT_ACTION(1<<0),
34         VLAN_VID_ACTION(1<<1),
35         VLAN_PCP_ACTION(1<<2),
36         VLAN_STRIP_ACTION(1<<3),
37         DLSRC_ACTION(1<<4),
38         DLDST_ACTION(1<<5),
39         NWSRC_ACTION(1<<6),
40         NWDST_ACTION(1<<7),
41         NWTOS_ACTION(1<<8),
42         TPTSRC_ACTION(1<<9),
43         TPTDST_ACTION(1<<10),
44         ENQUEUE_ACTION(1<<11),
45         VENDOR_ACTION(0xffff);
46         private final int at;
47         ActionType(int val) {
48                 this.at = val;
49         }
50         public int getValue() {
51                 return at;
52         }
53     }
54
55     public static final String ActionsPropName = "actions";
56     /**
57      * Construct a actions property
58      *
59      * @param actions the actions value
60      * @return Constructed object
61      */
62     public Actions(int actions) {
63         super(ActionsPropName);
64         this.actionsValue = actions;
65     }
66
67     /*
68      * Private constructor used for JAXB mapping
69      */
70     private Actions() {
71         super(ActionsPropName);
72         this.actionsValue = 0;
73     }
74
75     @Override
76     public Actions clone() {
77         return new Actions(this.actionsValue);
78     }
79
80     public int getValue() {
81         return this.actionsValue;
82     }
83
84
85     @Override
86     public int hashCode() {
87         final int prime = 31;
88         int result = super.hashCode();
89         result = prime * result + actionsValue;
90         return result;
91     }
92
93     @Override
94     public boolean equals(Object obj) {
95         if (this == obj)
96             return true;
97         if (!super.equals(obj))
98             return false;
99         if (getClass() != obj.getClass())
100             return false;
101         Actions other = (Actions) obj;
102         if (actionsValue != other.actionsValue)
103             return false;
104         return true;
105     }
106
107     @Override
108     public String toString() {
109         return "Actions[" + actionsValue + "]";
110     }
111
112     @Override
113     public String getStringValue() {
114         return Integer.toHexString(actionsValue);
115     }
116 }