Fixed the Policy API issues and Bugfixes
[policy/engine.git] / ECOMP-ControlloopPolicy / src / main / java / org / openecomp / policy / controlloop / policy / guard / ControlLoopGuard.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.openecomp.policy.controlloop.policy.guard;
21
22 import java.util.LinkedList;
23
24 public class ControlLoopGuard {
25         
26         private Guard guard;
27         
28         private LinkedList<GuardPolicy> guards;
29         
30         public ControlLoopGuard() {
31                 //DO Nothing Empty Constructor
32         }
33         
34         public Guard getGuard() {
35                 return guard;
36         }
37
38         public void setGuard(Guard guard) {
39                 this.guard = guard;
40         }
41
42         public LinkedList<GuardPolicy> getGuards() {
43                 return guards;
44         }
45
46         public void setGuards(LinkedList<GuardPolicy> guards) {
47                 this.guards = guards;
48         }
49
50         public ControlLoopGuard(ControlLoopGuard cLGuard) {
51                 this.guard = new Guard();
52                 this.guards = new LinkedList<>(cLGuard.guards);
53         }
54         
55         @Override
56         public String toString() {
57                 return "Guard [guard=" + guard + ", GuardPolicies=" + guards + "]";
58         }
59
60         @Override
61         public int hashCode() {
62                 final int prime = 31;
63                 int result = 1;
64                 result = prime * result + ((guard == null) ? 0 : guard.hashCode());
65                 result = prime * result + ((guards == null) ? 0 : guards.hashCode());
66                 return result;
67         }
68
69         @Override
70         public boolean equals(Object obj) {
71                 if (this == obj)
72                         return true;
73                 if (obj == null)
74                         return false;
75                 if (getClass() != obj.getClass())
76                         return false;
77                 ControlLoopGuard other = (ControlLoopGuard) obj;
78                 if (guard == null) {
79                         if (other.guard != null)
80                                 return false;
81                 } else if (!guard.equals(other.guard))
82                         return false;
83                 if (guards == null) {
84                         if (other.guards != null)
85                                 return false;
86                 } else if (!guards.equals(other.guards))
87                         return false;
88                 return true;
89         }
90
91         
92 }