2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.policy.controlloop.policy.guard;
24 import java.util.LinkedList;
25 import java.util.List;
28 public class MatchParameters {
29 private String controlLoopName;
31 private String recipe;
32 private List<String> targets;
34 public MatchParameters() {
35 // Do Nothing Empty Constructor.
38 public MatchParameters(String actor, String recipe) {
47 * @param recipe recipe
48 * @param targets targets
50 public MatchParameters(String actor, String recipe, List<String> targets) {
52 if (targets != null) {
53 this.targets = new LinkedList<>(targets);
57 public MatchParameters(String controlLoopName, String actor, String recipe, List<String> targets) {
58 this(actor, recipe, targets);
59 this.controlLoopName = controlLoopName;
65 * @param matchParameters match parameters
67 public MatchParameters(MatchParameters matchParameters) {
69 this.controlLoopName = matchParameters.controlLoopName;
70 this.actor = matchParameters.actor;
71 this.recipe = matchParameters.recipe;
72 if (matchParameters.targets != null) {
73 this.targets = new LinkedList<>(matchParameters.targets);
77 public String getControlLoopName() {
78 return controlLoopName;
81 public void setControlLoopName(String controlLoopName) {
82 this.controlLoopName = controlLoopName;
85 public String getActor() {
89 public void setActor(String actor) {
93 public String getRecipe() {
97 public void setRecipe(String recipe) {
101 public List<String> getTargets() {
105 public void setTargets(List<String> targets) {
106 this.targets = targets;
110 public String toString() {
111 return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe
112 + ", targets=" + targets + "]";
116 public int hashCode() {
117 final int prime = 31;
119 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
120 result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode());
121 result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
122 result = prime * result + ((targets == null) ? 0 : targets.hashCode());
127 public boolean equals(Object obj) {
134 if (getClass() != obj.getClass()) {
137 MatchParameters other = (MatchParameters) obj;
139 return equalsMayBeNull(actor, other.actor)
140 && equalsMayBeNull(controlLoopName, other.controlLoopName)
141 && equalsMayBeNull(recipe, other.recipe)
142 && equalsMayBeNull(targets, other.targets);
145 private boolean equalsMayBeNull(final Object obj1, final Object obj2) {
149 return obj1.equals(obj2);