fbfad741f5a82454e0329ac6c61181862a5bbe84
[policy/drools-applications.git] /
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * policy-yaml\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package org.onap.policy.controlloop.policy.guard;\r
22 \r
23 import java.util.LinkedList;\r
24 import java.util.List;\r
25 \r
26 \r
27 public class MatchParameters {\r
28     private String controlLoopName;\r
29     private String actor;\r
30     private String recipe;\r
31     private List<String> targets;\r
32 \r
33     public MatchParameters() {\r
34         // Do Nothing Empty Constructor.\r
35     }   \r
36     \r
37     public String getControlLoopName() {\r
38         return controlLoopName;\r
39     }\r
40 \r
41     public void setControlLoopName(String controlLoopName) {\r
42         this.controlLoopName = controlLoopName;\r
43     }\r
44 \r
45     public String getActor() {\r
46         return actor;\r
47     }\r
48 \r
49     public void setActor(String actor) {\r
50         this.actor = actor;\r
51     }\r
52 \r
53     public String getRecipe() {\r
54         return recipe;\r
55     }\r
56 \r
57     public void setRecipe(String recipe) {\r
58         this.recipe = recipe;\r
59     }\r
60 \r
61     public List<String> getTargets() {\r
62         return targets;\r
63     }\r
64 \r
65     public void setTargets(List<String> targets) {\r
66         this.targets = targets;\r
67     }\r
68 \r
69     public MatchParameters(String actor, String recipe) {\r
70         this.actor = actor;\r
71         this.recipe = recipe;\r
72     }\r
73 \r
74     public MatchParameters(String actor, String recipe, List<String> targets) {\r
75         this(actor, recipe);\r
76         if (targets != null) {\r
77             this.targets = new LinkedList<>(targets);\r
78         }\r
79     }\r
80 \r
81     public MatchParameters(String controlLoopName, String actor, String recipe, List<String> targets) {\r
82         this(actor, recipe, targets);\r
83         this.controlLoopName = controlLoopName;\r
84     }\r
85 \r
86     public MatchParameters(MatchParameters matchParameters) {\r
87 \r
88         this.controlLoopName = matchParameters.controlLoopName;\r
89         this.actor = matchParameters.actor;\r
90         this.recipe = matchParameters.recipe;\r
91         if (matchParameters.targets != null) {\r
92             this.targets = new LinkedList<>(matchParameters.targets);\r
93         }\r
94     }\r
95 \r
96     @Override\r
97     public String toString() {\r
98         return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe\r
99                 + ", targets=" + targets + "]";\r
100     }\r
101 \r
102     @Override\r
103     public int hashCode() {\r
104         final int prime = 31;\r
105         int result = 1;\r
106         result = prime * result + ((actor == null) ? 0 : actor.hashCode());\r
107         result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode());\r
108         result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());\r
109         result = prime * result + ((targets == null) ? 0 : targets.hashCode());\r
110         return result;\r
111     }\r
112 \r
113     @Override\r
114     public boolean equals(Object obj) {\r
115         if (this == obj)\r
116             return true;\r
117         if (obj == null)\r
118             return false;\r
119         if (getClass() != obj.getClass())\r
120             return false;\r
121         MatchParameters other = (MatchParameters) obj;\r
122         if (actor == null) {\r
123             if (other.actor != null)\r
124                 return false;\r
125         } else if (!actor.equals(other.actor))\r
126             return false;\r
127         if (controlLoopName == null) {\r
128             if (other.controlLoopName != null)\r
129                 return false;\r
130         } else if (!controlLoopName.equals(other.controlLoopName))\r
131             return false;\r
132         if (recipe == null) {\r
133             if (other.recipe != null)\r
134                 return false;\r
135         } else if (!recipe.equals(other.recipe))\r
136             return false;\r
137         if (targets == null) {\r
138             if (other.targets != null)\r
139                 return false;\r
140         } else if (!targets.equals(other.targets))\r
141             return false;\r
142         return true;\r
143     }\r
144 }\r