Enhancement to switchmanager CLI commands to display all the properties of node and...
[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.XmlElement;
13 import javax.xml.bind.annotation.XmlRootElement;
14
15 /**
16  * @file   Actions.java
17  *
18  * @brief  Class representing actions
19  *
20  * Describes supported actions
21  */
22
23 @XmlRootElement
24 public class Actions extends Property {
25         private static final long serialVersionUID = 1L;
26     @XmlElement(name="value")
27     private int actionsValue;
28
29     public enum ActionType {
30         OUTPUT_PORT_ACTION(1<<0),
31         VLAN_VID_ACTION(1<<1),
32         VLAN_PCP_ACTION(1<<2),
33         VLAN_STRIP_ACTION(1<<3),
34         DLSRC_ACTION(1<<4),
35         DLDST_ACTION(1<<5),
36         NWSRC_ACTION(1<<6),
37         NWDST_ACTION(1<<7),
38         NWTOS_ACTION(1<<8),
39         TPTSRC_ACTION(1<<9),
40         TPTDST_ACTION(1<<10),
41         ENQUEUE_ACTION(1<<11),
42         VENDOR_ACTION(0xffff);
43         private final int at;
44         ActionType(int val) {
45                 this.at = val;
46         }
47         public int getValue() {
48                 return at;
49         }
50     }
51
52     public static final String ActionsPropName = "actions";
53     /**
54      * Construct a actions property
55      *
56      * @param actions the actions value
57      * @return Constructed object
58      */
59     public Actions(int actions) {
60         super(ActionsPropName);
61         this.actionsValue = actions;
62     }
63
64     /*
65      * Private constructor used for JAXB mapping
66      */
67     private Actions() {
68         super(ActionsPropName);
69         this.actionsValue = 0;
70     }
71
72     @Override
73     public Actions clone() {
74         return new Actions(this.actionsValue);
75     }
76
77     public int getValue() {
78         return this.actionsValue;
79     }
80
81
82     @Override
83     public int hashCode() {
84         final int prime = 31;
85         int result = super.hashCode();
86         result = prime * result + actionsValue;
87         return result;
88     }
89
90     @Override
91     public boolean equals(Object obj) {
92         if (this == obj)
93             return true;
94         if (!super.equals(obj))
95             return false;
96         if (getClass() != obj.getClass())
97             return false;
98         Actions other = (Actions) obj;
99         if (actionsValue != other.actionsValue)
100             return false;
101         return true;
102     }
103
104     @Override
105     public String toString() {
106         return "Actions[" + actionsValue + "]";
107     }
108
109     @Override
110     public String getStringValue() {
111         return Integer.toHexString(actionsValue);
112     }
113 }