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 public String id = UUID.randomUUID().toString();
31 public String description;
34 public LinkedList<Constraint> limit_constraints;
36 public GuardPolicy() {
40 public GuardPolicy(String id) {
44 public GuardPolicy(String name, String actor, String recipe) {
50 public GuardPolicy(String id, String name, String description, String actor, String recipe) {
51 this(name, actor, recipe);
53 this.description = description;
56 public GuardPolicy(String name, String actor, String recipe, List<Constraint> limit_constraints) {
57 this(name, actor, recipe);
58 if (limit_constraints != null) {
59 this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(limit_constraints);
63 public GuardPolicy(String name, String description, String actor, String recipe, List<Constraint> limit_constraints) {
64 this(name, actor, recipe, limit_constraints);
65 this.description = description;
68 public GuardPolicy(String id, String name, String description, String actor, String recipe, List<Constraint> limit_constraints) {
69 this(name, description, actor, recipe, limit_constraints);
73 public GuardPolicy(GuardPolicy policy) {
75 this.name = policy.name;
76 this.description = policy.description;
77 this.actor = policy.actor;
78 this.recipe = policy.recipe;
79 if (policy.limit_constraints != null) {
80 this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(policy.limit_constraints);
84 public boolean isValid() {
87 throw new NullPointerException();
90 throw new NullPointerException();
93 throw new NullPointerException();
96 throw new NullPointerException();
98 } catch (Exception e) {
105 public String toString() {
106 return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", actor=" + actor + ", recipe="
107 + recipe + ", limit_constraints=" + limit_constraints + "]";
111 public int hashCode() {
112 final int prime = 31;
114 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
115 result = prime * result + ((description == null) ? 0 : description.hashCode());
116 result = prime * result + ((id == null) ? 0 : id.hashCode());
117 result = prime * result + ((name == null) ? 0 : name.hashCode());
118 result = prime * result + ((limit_constraints == null) ? 0 : limit_constraints.hashCode());
119 result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
124 public boolean equals(Object obj) {
129 if (getClass() != obj.getClass())
131 GuardPolicy other = (GuardPolicy) obj;
133 if (other.actor != null)
135 } else if (!actor.equals(other.actor))
137 if (description == null) {
138 if (other.description != null)
140 } else if (!description.equals(other.description))
143 if (other.id != null)
145 } else if (!id.equals(other.id))
148 if (other.name != null)
150 } else if (!name.equals(other.name))
152 if (limit_constraints == null) {
153 if (other.limit_constraints != null)
155 } else if (!limit_constraints.equals(other.limit_constraints))
157 if (recipe == null) {
158 if (other.recipe != null)
160 } else if (!recipe.equals(other.recipe))