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