c96ecf710a3387be0e8343fb04e39757308bdaa4
[policy/drools-applications.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * policy-yaml
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
21 package org.onap.policy.controlloop.policy.guard;
22
23 import java.util.LinkedList;
24
25
26 public class MatchParameters {
27
28         //public ControlLoopParameter controlLoop;
29         public String controlLoopName;
30         public String actor;
31         public String recipe;
32         public LinkedList<String> targets;
33         
34         
35         public MatchParameters() {
36
37         }
38         
39         public MatchParameters(String actor, String recipe) {
40                 this.actor = actor;
41                 this.recipe = recipe;
42         }
43
44         public MatchParameters(String actor, String recipe, LinkedList<String> targets) {
45                 this(actor, recipe);
46                 if (targets != null) {
47                         this.targets = new LinkedList<String>(targets);
48                 }
49         }
50         
51         
52         public MatchParameters(String controlLoopName, String actor, String recipe, LinkedList<String> targets) {
53                 this(actor, recipe, targets);
54                 this.controlLoopName = controlLoopName;
55         }
56         
57         
58
59
60         
61         public MatchParameters(MatchParameters matchParameters) {
62
63                 this.controlLoopName = matchParameters.controlLoopName;
64                 this.actor = matchParameters.actor;
65                 this.recipe = matchParameters.recipe;
66                 if (matchParameters.targets != null) {
67                         //this.targets = (LinkedList<String>) Collections.unmodifiableList(matchParameters.targets);
68                         this.targets = new LinkedList<String>(matchParameters.targets);
69                 }
70         }
71         
72         /*
73         public boolean isValid() {
74                 try {
75                         if (actor == null) {
76                                 throw new NullPointerException();
77                         }
78                         if (recipe == null) {
79                                 throw new NullPointerException();
80                         }
81                 } catch (Exception e) {
82                         return false;
83                 }
84                 return true;
85         }
86         */
87         
88         @Override
89         public String toString() {
90                 return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe
91                                 + ", targets=" + targets + "]";
92         }
93
94         @Override
95         public int hashCode() {
96                 final int prime = 31;
97                 int result = 1;
98                 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
99                 result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode());
100                 result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
101                 result = prime * result + ((targets == null) ? 0 : targets.hashCode());
102                 return result;
103         }
104
105         @Override
106         public boolean equals(Object obj) {
107                 if (this == obj)
108                         return true;
109                 if (obj == null)
110                         return false;
111                 if (getClass() != obj.getClass())
112                         return false;
113                 MatchParameters other = (MatchParameters) obj;
114                 if (actor == null) {
115                         if (other.actor != null)
116                                 return false;
117                 } else if (!actor.equals(other.actor))
118                         return false;
119                 if (controlLoopName == null) {
120                         if (other.controlLoopName != null)
121                                 return false;
122                 } else if (!controlLoopName.equals(other.controlLoopName))
123                         return false;
124                 if (recipe == null) {
125                         if (other.recipe != null)
126                                 return false;
127                 } else if (!recipe.equals(other.recipe))
128                         return false;
129                 if (targets == null) {
130                         if (other.targets != null)
131                                 return false;
132                 } else if (!targets.equals(other.targets))
133                         return false;
134                 return true;
135         }
136         
137         
138 }