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=========================================================
20 package org.openecomp.policy.controlloop.policy.guard;
22 import java.util.Collections;
23 import java.util.LinkedList;
24 import java.util.List;
25 import java.util.UUID;
27 public class GuardPolicy {
29 private String id = UUID.randomUUID().toString();
31 private String description;
33 private String recipe;
34 private LinkedList<Constraint> limit_constraints;
36 public GuardPolicy() {
37 //Do Nothing Empty Constructor.
40 public String getId() {
44 public void setId(String id) {
48 public String getName() {
52 public void setName(String name) {
56 public String getDescription() {
60 public void setDescription(String description) {
61 this.description = description;
64 public String getActor() {
68 public void setActor(String actor) {
72 public String getRecipe() {
76 public void setRecipe(String recipe) {
80 public LinkedList<Constraint> getLimit_constraints() {
81 return limit_constraints;
84 public void setLimit_constraints(LinkedList<Constraint> limit_constraints) {
85 this.limit_constraints = limit_constraints;
88 public GuardPolicy(String id) {
92 public GuardPolicy(String name, String actor, String recipe) {
98 public GuardPolicy(String id, String name, String description, String actor, String recipe) {
99 this(name, actor, recipe);
101 this.description = description;
104 public GuardPolicy(String name, String actor, String recipe, List<Constraint> limit_constraints) {
105 this(name, actor, recipe);
106 if (limit_constraints != null) {
107 this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(limit_constraints);
111 public GuardPolicy(String name, String description, String actor, String recipe, List<Constraint> limit_constraints) {
112 this(name, actor, recipe, limit_constraints);
113 this.description = description;
116 public GuardPolicy(String id, String name, String description, String actor, String recipe, List<Constraint> limit_constraints) {
117 this(name, description, actor, recipe, limit_constraints);
121 public GuardPolicy(GuardPolicy policy) {
123 this.name = policy.name;
124 this.description = policy.description;
125 this.actor = policy.actor;
126 this.recipe = policy.recipe;
127 if (policy.limit_constraints != null) {
128 this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(policy.limit_constraints);
132 public boolean isValid() {
133 if(id==null || name ==null|| actor==null|| recipe==null){
140 public String toString() {
141 return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", actor=" + actor + ", recipe="
142 + recipe + ", limitConstraints=" + limit_constraints + "]";
146 public int hashCode() {
147 final int prime = 31;
149 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
150 result = prime * result + ((description == null) ? 0 : description.hashCode());
151 result = prime * result + ((id == null) ? 0 : id.hashCode());
152 result = prime * result + ((name == null) ? 0 : name.hashCode());
153 result = prime * result + ((limit_constraints == null) ? 0 : limit_constraints.hashCode());
154 result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
159 public boolean equals(Object obj) {
164 if (getClass() != obj.getClass())
166 GuardPolicy other = (GuardPolicy) obj;
168 if (other.actor != null)
170 } else if (!actor.equals(other.actor))
172 if (description == null) {
173 if (other.description != null)
175 } else if (!description.equals(other.description))
178 if (other.id != null)
180 } else if (!id.equals(other.id))
183 if (other.name != null)
185 } else if (!name.equals(other.name))
187 if (limit_constraints == null) {
188 if (other.limit_constraints != null)
190 } else if (!limit_constraints.equals(other.limit_constraints))
192 if (recipe == null) {
193 if (other.recipe != null)
195 } else if (!recipe.equals(other.recipe))