7c90801ecae020155704504a600e8b4e840d8c8c
[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 \r
25 public class ControlLoopGuard {\r
26     \r
27     private Guard guard;\r
28     \r
29     private LinkedList<GuardPolicy> guards;\r
30     \r
31     public ControlLoopGuard() {\r
32         //DO Nothing Empty Constructor\r
33     }\r
34     \r
35     public Guard getGuard() {\r
36         return guard;\r
37     }\r
38 \r
39     public void setGuard(Guard guard) {\r
40         this.guard = guard;\r
41     }\r
42 \r
43     public LinkedList<GuardPolicy> getGuards() {\r
44         return guards;\r
45     }\r
46 \r
47     public void setGuards(LinkedList<GuardPolicy> guards) {\r
48         this.guards = guards;\r
49     }\r
50 \r
51     public ControlLoopGuard(ControlLoopGuard cLGuard) {\r
52         this.guard = new Guard();\r
53         this.guards = new LinkedList<>(cLGuard.guards);\r
54     }\r
55     \r
56     @Override\r
57     public String toString() {\r
58         return "Guard [guard=" + guard + ", GuardPolicies=" + guards + "]";\r
59     }\r
60 \r
61     @Override\r
62     public int hashCode() {\r
63         final int prime = 31;\r
64         int result = 1;\r
65         result = prime * result + ((guard == null) ? 0 : guard.hashCode());\r
66         result = prime * result + ((guards == null) ? 0 : guards.hashCode());\r
67         return result;\r
68     }\r
69 \r
70     @Override\r
71     public boolean equals(Object obj) {\r
72         if (this == obj)\r
73             return true;\r
74         if (obj == null)\r
75             return false;\r
76         if (getClass() != obj.getClass())\r
77             return false;\r
78         ControlLoopGuard other = (ControlLoopGuard) obj;\r
79         if (guard == null) {\r
80             if (other.guard != null)\r
81                 return false;\r
82         } else if (!guard.equals(other.guard))\r
83             return false;\r
84         if (guards == null) {\r
85             if (other.guards != null)\r
86                 return false;\r
87         } else if (!guards.equals(other.guards))\r
88             return false;\r
89         return true;\r
90     }\r
91 \r
92     \r
93 }\r