Merge "Bug 1029: Remove dead code: samples/clustersession"
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / action / SupportedFlowActions.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, 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
9 package org.opendaylight.controller.sal.action;
10
11 import java.util.ArrayList;
12 import java.util.Collections;
13 import java.util.List;
14
15 import javax.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlElement;
18
19 import org.opendaylight.controller.sal.core.Property;
20
21 /**
22  * @file SupportedFlowActions.java
23  *
24  * @brief Class representing the supported flow actions
25  *
26  *        Describes the supported flow actions
27  */
28
29 @XmlAccessorType(XmlAccessType.NONE)
30 public class SupportedFlowActions extends Property {
31     private static final long serialVersionUID = 1L;
32     public static final String SupportedFlowActionsPropName = "supportedFlowActions";
33     private List<Class<? extends Action>> actions;
34
35     private SupportedFlowActions() {
36         super(SupportedFlowActionsPropName);
37         this.actions = new ArrayList<Class<? extends Action>>();
38     }
39
40     public SupportedFlowActions(List<Class<? extends Action>> actions) {
41         super(SupportedFlowActionsPropName);
42         this.actions = new ArrayList<Class<? extends Action>>(actions);
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 31;
48         int result = super.hashCode();
49         result = prime * result + ((actions == null) ? 0 : actions.hashCode());
50         return result;
51     }
52
53     @Override
54     public boolean equals(Object obj) {
55         if (this == obj) {
56             return true;
57         }
58         if (!super.equals(obj)) {
59             return false;
60         }
61         if (getClass() != obj.getClass()) {
62             return false;
63         }
64         SupportedFlowActions other = (SupportedFlowActions) obj;
65         if (actions == null) {
66             if (other.actions != null) {
67                 return false;
68             }
69         } else if (!actions.equals(other.actions)) {
70             return false;
71         }
72         return true;
73     }
74
75     public List<Class<? extends Action>> getActions() {
76         return new ArrayList<Class<? extends Action>>(this.actions);
77     }
78
79     @XmlElement(name = "value")
80     @Override
81     public String getStringValue() {
82         List<String> nameList = new ArrayList<String>();
83         for (Class<? extends Action> clazz : actions) {
84             nameList.add(clazz.getSimpleName());
85         }
86         Collections.sort(nameList);
87         return nameList.toString();
88     }
89
90     @Override
91     public Property clone() {
92         return new SupportedFlowActions(this.actions);
93     }
94
95     @Override
96     public String toString() {
97         return this.getStringValue();
98     }
99 }