2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.onap.policy.controlloop.policy.guard;
\r
23 import java.util.Collections;
\r
24 import java.util.LinkedList;
\r
25 import java.util.List;
\r
26 import java.util.UUID;
\r
28 public class GuardPolicy {
\r
30 private String id = UUID.randomUUID().toString();
\r
31 private String name;
\r
32 private String description;
\r
33 private MatchParameters match_parameters;
\r
34 private LinkedList<Constraint> limit_constraints;
\r
36 public GuardPolicy() {
\r
37 //Do Nothing Empty Constructor.
\r
40 public String getId() {
\r
44 public void setId(String id) {
\r
48 public String getName() {
\r
52 public void setName(String name) {
\r
56 public String getDescription() {
\r
60 public void setDescription(String description) {
\r
61 this.description = description;
\r
64 public MatchParameters getMatch_parameters() {
\r
65 return match_parameters;
\r
68 public void setMatch_parameters(MatchParameters match_parameters) {
\r
69 this.match_parameters = match_parameters;
\r
72 public LinkedList<Constraint> getLimit_constraints() {
\r
73 return limit_constraints;
\r
76 public void setLimit_constraints(LinkedList<Constraint> limit_constraints) {
\r
77 this.limit_constraints = limit_constraints;
\r
80 public GuardPolicy(String id) {
\r
84 public GuardPolicy(String name, MatchParameters matchParameters) {
\r
86 this.match_parameters = matchParameters;
\r
89 public GuardPolicy(String id, String name, String description, MatchParameters matchParameters) {
\r
90 this(name, matchParameters);
\r
92 this.description = description;
\r
95 public GuardPolicy(String name, MatchParameters matchParameters, List<Constraint> limitConstraints) {
\r
96 this(name, matchParameters);
\r
97 if (limit_constraints != null) {
\r
98 this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(limitConstraints);
\r
102 public GuardPolicy(String name, String description, MatchParameters matchParameters, List<Constraint> limitConstraints) {
\r
103 this(name, matchParameters, limitConstraints);
\r
104 this.description = description;
\r
107 public GuardPolicy(String id, String name, String description, MatchParameters matchParameters, List<Constraint> limitConstraints) {
\r
108 this(name, description, matchParameters, limitConstraints);
\r
112 public GuardPolicy(GuardPolicy policy) {
\r
113 this.id = policy.id;
\r
114 this.name = policy.name;
\r
115 this.description = policy.description;
\r
116 this.match_parameters = new MatchParameters(policy.match_parameters);
\r
117 if (policy.limit_constraints != null) {
\r
118 this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(policy.limit_constraints);
\r
122 public boolean isValid() {
\r
123 return (id==null || name ==null)? false : true;
\r
127 public String toString() {
\r
128 return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", match_parameters="
\r
129 +match_parameters + ", limitConstraints=" + limit_constraints + "]";
\r
133 public int hashCode() {
\r
134 final int prime = 31;
\r
136 result = prime * result + ((description == null) ? 0 : description.hashCode());
\r
137 result = prime * result + ((id == null) ? 0 : id.hashCode());
\r
138 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
139 result = prime * result + ((limit_constraints == null) ? 0 : limit_constraints.hashCode());
\r
140 result = prime * result + ((match_parameters == null) ? 0 : match_parameters.hashCode());
\r
145 public boolean equals(Object obj) {
\r
150 if (getClass() != obj.getClass())
\r
152 GuardPolicy other = (GuardPolicy) obj;
\r
153 if (description == null) {
\r
154 if (other.description != null)
\r
156 } else if (!description.equals(other.description))
\r
159 if (other.id != null)
\r
161 } else if (!id.equals(other.id))
\r
163 if (name == null) {
\r
164 if (other.name != null)
\r
166 } else if (!name.equals(other.name))
\r
168 if (limit_constraints == null) {
\r
169 if (other.limit_constraints != null)
\r
171 } else if (!limit_constraints.equals(other.limit_constraints))
\r
173 if (match_parameters==null){
\r
174 if(other.match_parameters !=null)
\r
176 } else if(!match_parameters.equals(other.match_parameters))
\r