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;
23 import java.util.LinkedList;
24 import java.util.List;
26 import org.onap.policy.asdc.Resource;
27 import org.onap.policy.asdc.Service;
29 public class ControlLoop {
31 private static String VERSION = "2.0.0";
33 private String controlLoopName;
34 private String version = VERSION;
35 private List<Service> services;
36 private List<Resource> resources;
37 private String trigger_policy = FinalResult.FINAL_OPENLOOP.toString();
38 private Integer timeout;
39 private Boolean abatement = false;
41 public ControlLoop() {
45 public static String getVERSION(){
46 return ControlLoop.VERSION;
49 public String getControlLoopName() {
50 return controlLoopName;
53 public void setControlLoopName(String controlLoopName) {
54 this.controlLoopName = controlLoopName;
57 public List<Service> getServices() {
61 public void setServices(List<Service> services) {
62 this.services = services;
65 public List<Resource> getResources() {
69 public void setResources(List<Resource> resources) {
70 this.resources = resources;
73 public String getTrigger_policy() {
74 return trigger_policy;
77 public void setTrigger_policy(String trigger_policy) {
78 this.trigger_policy = trigger_policy;
81 public Integer getTimeout() {
85 public void setTimeout(Integer timeout) {
86 this.timeout = timeout;
89 public Boolean getAbatement() {
93 public void setAbatement(Boolean abatement) {
94 this.abatement = abatement;
97 public String getVersion() {
101 public void setVersion(String version){
102 this.version = version;
105 public ControlLoop(ControlLoop controlLoop) {
106 this.controlLoopName = controlLoop.controlLoopName;
107 this.services = new LinkedList<>();
108 if (controlLoop.services != null) {
109 for (Service service : controlLoop.services) {
110 this.services.add(service);
113 this.resources = new LinkedList<>();
114 if (controlLoop.resources != null) {
115 for (Resource resource: controlLoop.resources) {
116 this.resources.add(resource);
119 this.trigger_policy = controlLoop.trigger_policy;
120 this.timeout = controlLoop.timeout;
121 this.abatement = controlLoop.abatement;
124 public String toString() {
125 return "ControlLoop [controlLoopName=" + controlLoopName + ", version=" + version + ", services=" + services
126 + ", resources=" + resources + ", trigger_policy=" + trigger_policy + ", timeout="
127 + timeout + ", abatement=" + abatement + "]";
130 public int hashCode() {
131 final int prime = 31;
133 result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode());
134 result = prime * result + ((resources == null) ? 0 : resources.hashCode());
135 result = prime * result + ((services == null) ? 0 : services.hashCode());
136 result = prime * result + ((timeout == null) ? 0 : timeout.hashCode());
137 result = prime * result + ((trigger_policy == null) ? 0 : trigger_policy.hashCode());
138 result = prime * result + ((version == null) ? 0 : version.hashCode());
139 result = prime * result + ((abatement == null) ? 0 : abatement.hashCode());
143 public boolean equals(Object obj) {
148 if (getClass() != obj.getClass())
150 ControlLoop other = (ControlLoop) obj;
151 if (controlLoopName == null) {
152 if (other.controlLoopName != null)
154 } else if (!controlLoopName.equals(other.controlLoopName))
156 if (resources == null) {
157 if (other.resources != null)
159 } else if (!resources.equals(other.resources))
161 if (services == null) {
162 if (other.services != null)
164 } else if (!services.equals(other.services))
166 if (timeout == null) {
167 if (other.timeout != null)
169 } else if (!timeout.equals(other.timeout))
171 if (trigger_policy == null) {
172 if (other.trigger_policy != null)
174 } else if (!trigger_policy.equals(other.trigger_policy))
176 if (version == null) {
177 if (other.version != null)
179 } else if (!version.equals(other.version))
181 if (abatement == null) {
182 if (other.abatement != null)
184 } else if (!abatement.equals(other.abatement))