2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 MatchParameters(String actor, String recipe) {
46 * @param recipe recipe
47 * @param targets targets
49 public MatchParameters(String actor, String recipe, List<String> targets) {
51 if (targets != null) {
52 this.targets = new LinkedList<>(targets);
56 public MatchParameters(String controlLoopName, String actor, String recipe, List<String> targets) {
57 this(actor, recipe, targets);
58 this.controlLoopName = controlLoopName;
64 * @param matchParameters match parameters
66 public MatchParameters(MatchParameters matchParameters) {
68 this.controlLoopName = matchParameters.controlLoopName;
69 this.actor = matchParameters.actor;
70 this.recipe = matchParameters.recipe;
71 if (matchParameters.targets != null) {
72 this.targets = new LinkedList<>(matchParameters.targets);
76 public String getControlLoopName() {
77 return controlLoopName;
80 public void setControlLoopName(String controlLoopName) {
81 this.controlLoopName = controlLoopName;
84 public String getActor() {
88 public void setActor(String actor) {
92 public String getRecipe() {
96 public void setRecipe(String recipe) {
100 public List<String> getTargets() {
104 public void setTargets(List<String> targets) {
105 this.targets = targets;
109 public String toString() {
110 return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe
111 + ", targets=" + targets + "]";
115 public int hashCode() {
116 final int prime = 31;
118 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
119 result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode());
120 result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
121 result = prime * result + ((targets == null) ? 0 : targets.hashCode());
126 public boolean equals(Object obj) {
133 if (getClass() != obj.getClass()) {
136 MatchParameters other = (MatchParameters) obj;
138 return equalsMayBeNull(actor, other.actor)
139 && equalsMayBeNull(controlLoopName, other.controlLoopName)
140 && equalsMayBeNull(recipe, other.recipe)
141 && equalsMayBeNull(targets, other.targets);
144 private boolean equalsMayBeNull(final Object obj1, final Object obj2) {
148 return obj1.equals(obj2);