Make sure invokeOperation is set once
[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 @Deprecated
31 public class SupportedFlowActions extends Property {
32     private static final long serialVersionUID = 1L;
33     public static final String SupportedFlowActionsPropName = "supportedFlowActions";
34     private List<Class<? extends Action>> actions;
35
36     private SupportedFlowActions() {
37         super(SupportedFlowActionsPropName);
38         this.actions = new ArrayList<Class<? extends Action>>();
39     }
40
41     public SupportedFlowActions(List<Class<? extends Action>> actions) {
42         super(SupportedFlowActionsPropName);
43         this.actions = new ArrayList<Class<? extends Action>>(actions);
44     }
45
46     @Override
47     public int hashCode() {
48         final int prime = 31;
49         int result = super.hashCode();
50         result = prime * result + ((actions == null) ? 0 : actions.hashCode());
51         return result;
52     }
53
54     @Override
55     public boolean equals(Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (!super.equals(obj)) {
60             return false;
61         }
62         if (getClass() != obj.getClass()) {
63             return false;
64         }
65         SupportedFlowActions other = (SupportedFlowActions) obj;
66         if (actions == null) {
67             if (other.actions != null) {
68                 return false;
69             }
70         } else if (!actions.equals(other.actions)) {
71             return false;
72         }
73         return true;
74     }
75
76     public List<Class<? extends Action>> getActions() {
77         return new ArrayList<Class<? extends Action>>(this.actions);
78     }
79
80     @XmlElement(name = "value")
81     @Override
82     public String getStringValue() {
83         List<String> nameList = new ArrayList<String>();
84         for (Class<? extends Action> clazz : actions) {
85             nameList.add(clazz.getSimpleName());
86         }
87         Collections.sort(nameList);
88         return nameList.toString();
89     }
90
91     @Override
92     public Property clone() {
93         return new SupportedFlowActions(this.actions);
94     }
95
96     @Override
97     public String toString() {
98         return this.getStringValue();
99     }
100 }