2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.controlloop.policy.guard;
23 import java.util.LinkedList;
24 import java.util.List;
27 public class MatchParameters {
28 private String controlLoopName;
30 private String recipe;
31 private List<String> targets;
33 public MatchParameters() {
34 // Do Nothing Empty Constructor.
37 public String getControlLoopName() {
38 return controlLoopName;
41 public void setControlLoopName(String controlLoopName) {
42 this.controlLoopName = controlLoopName;
45 public String getActor() {
49 public void setActor(String actor) {
53 public String getRecipe() {
57 public void setRecipe(String recipe) {
61 public List<String> getTargets() {
65 public void setTargets(List<String> targets) {
66 this.targets = targets;
69 public MatchParameters(String actor, String recipe) {
74 public MatchParameters(String actor, String recipe, List<String> targets) {
76 if (targets != null) {
77 this.targets = new LinkedList<>(targets);
81 public MatchParameters(String controlLoopName, String actor, String recipe, List<String> targets) {
82 this(actor, recipe, targets);
83 this.controlLoopName = controlLoopName;
86 public MatchParameters(MatchParameters matchParameters) {
88 this.controlLoopName = matchParameters.controlLoopName;
89 this.actor = matchParameters.actor;
90 this.recipe = matchParameters.recipe;
91 if (matchParameters.targets != null) {
92 this.targets = new LinkedList<>(matchParameters.targets);
97 public String toString() {
98 return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe
99 + ", targets=" + targets + "]";
103 public int hashCode() {
104 final int prime = 31;
106 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
107 result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode());
108 result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
109 result = prime * result + ((targets == null) ? 0 : targets.hashCode());
114 public boolean equals(Object obj) {
119 if (getClass() != obj.getClass())
121 MatchParameters other = (MatchParameters) obj;
123 return equalsMayBeNull(actor, other.actor)
124 && equalsMayBeNull(controlLoopName, other.controlLoopName)
125 && equalsMayBeNull(recipe, other.recipe)
126 && equalsMayBeNull(targets, other.targets);
129 private boolean equalsMayBeNull(final Object obj1, final Object obj2){
130 if ( obj1 == null ) {
133 return obj1.equals(obj2);