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=========================================================
21 package org.onap.policy.controlloop.policy.guard;
23 import java.util.Collections;
24 import java.util.LinkedList;
25 import java.util.List;
26 import java.util.UUID;
28 public class GuardPolicy {
30 public String id = UUID.randomUUID().toString();
32 public String description;
35 public LinkedList<Constraint> limit_constraints;
37 public GuardPolicy() {
41 public GuardPolicy(String id) {
45 public GuardPolicy(String name, String actor, String recipe) {
51 public GuardPolicy(String id, String name, String description, String actor, String recipe) {
52 this(name, actor, recipe);
54 this.description = description;
57 public GuardPolicy(String name, String actor, String recipe, List<Constraint> limit_constraints) {
58 this(name, actor, recipe);
59 if (limit_constraints != null) {
60 this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(limit_constraints);
64 public GuardPolicy(String name, String description, String actor, String recipe, List<Constraint> limit_constraints) {
65 this(name, actor, recipe, limit_constraints);
66 this.description = description;
69 public GuardPolicy(String id, String name, String description, String actor, String recipe, List<Constraint> limit_constraints) {
70 this(name, description, actor, recipe, limit_constraints);
74 public GuardPolicy(GuardPolicy policy) {
76 this.name = policy.name;
77 this.description = policy.description;
78 this.actor = policy.actor;
79 this.recipe = policy.recipe;
80 if (policy.limit_constraints != null) {
81 this.limit_constraints = (LinkedList<Constraint>) Collections.unmodifiableList(policy.limit_constraints);
85 public boolean isValid() {
88 throw new NullPointerException();
91 throw new NullPointerException();
94 throw new NullPointerException();
97 throw new NullPointerException();
99 } catch (Exception e) {
106 public String toString() {
107 return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", actor=" + actor + ", recipe="
108 + recipe + ", limit_constraints=" + limit_constraints + "]";
112 public int hashCode() {
113 final int prime = 31;
115 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
116 result = prime * result + ((description == null) ? 0 : description.hashCode());
117 result = prime * result + ((id == null) ? 0 : id.hashCode());
118 result = prime * result + ((name == null) ? 0 : name.hashCode());
119 result = prime * result + ((limit_constraints == null) ? 0 : limit_constraints.hashCode());
120 result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
125 public boolean equals(Object obj) {
130 if (getClass() != obj.getClass())
132 GuardPolicy other = (GuardPolicy) obj;
134 if (other.actor != null)
136 } else if (!actor.equals(other.actor))
138 if (description == null) {
139 if (other.description != null)
141 } else if (!description.equals(other.description))
144 if (other.id != null)
146 } else if (!id.equals(other.id))
149 if (other.name != null)
151 } else if (!name.equals(other.name))
153 if (limit_constraints == null) {
154 if (other.limit_constraints != null)
156 } else if (!limit_constraints.equals(other.limit_constraints))
158 if (recipe == null) {
159 if (other.recipe != null)
161 } else if (!recipe.equals(other.recipe))