Checkstyle enforcer
[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
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     public Actions clone() {
73         return new Actions(this.actionsValue);
74     }
75
76     public int getValue() {
77         return this.actionsValue;
78     }
79
80
81     @Override
82     public int hashCode() {
83         final int prime = 31;
84         int result = super.hashCode();
85         result = prime * result + actionsValue;
86         return result;
87     }
88
89     @Override
90     public boolean equals(Object obj) {
91         if (this == obj)
92             return true;
93         if (!super.equals(obj))
94             return false;
95         if (getClass() != obj.getClass())
96             return false;
97         Actions other = (Actions) obj;
98         if (actionsValue != other.actionsValue)
99             return false;
100         return true;
101     }
102
103     @Override
104     public String toString() {
105         return "Actions[" + actionsValue + "]";
106     }
107 }