* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
package org.onap.policy.controlloop.policy.guard;
-import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
private String name;
private String description;
private MatchParameters matchParameters;
- private LinkedList<Constraint> limitConstraints;
-
+ private List<Constraint> limitConstraints;
+
public GuardPolicy() {
- //Do Nothing Empty Constructor.
+ //Do Nothing Empty Constructor.
}
-
+
public GuardPolicy(String id) {
this.id = id;
}
-
+
public GuardPolicy(String name, MatchParameters matchParameters) {
this.name = name;
this.matchParameters = matchParameters;
}
-
+
/**
* Constructor.
- *
+ *
* @param id id
* @param name name
* @param description description
this.id = id;
this.description = description;
}
-
+
/**
* Constructor.
- *
+ *
* @param name name
* @param matchParameters match parameters
* @param limitConstraints limit constraints
*/
public GuardPolicy(String name, MatchParameters matchParameters, List<Constraint> limitConstraints) {
this(name, matchParameters);
- if (limitConstraints != null) {
- this.limitConstraints = (LinkedList<Constraint>) limitConstraints;
- }
+ this.limitConstraints = limitConstraints;
}
-
- public GuardPolicy(String name, String description, MatchParameters matchParameters,
+
+ public GuardPolicy(String name, String description, MatchParameters matchParameters,
List<Constraint> limitConstraints) {
this(name, matchParameters, limitConstraints);
this.description = description;
}
-
- public GuardPolicy(String id, String name, String description, MatchParameters matchParameters,
+
+ public GuardPolicy(String id, String name, String description, MatchParameters matchParameters,
List<Constraint> limitConstraints) {
this(name, description, matchParameters, limitConstraints);
this.id = id;
}
-
+
/**
* Constructor.
- *
+ *
* @param policy copy object
*/
public GuardPolicy(GuardPolicy policy) {
this.name = policy.name;
this.description = policy.description;
this.matchParameters = new MatchParameters(policy.matchParameters);
- if (policy.limitConstraints != null) {
- this.limitConstraints = policy.limitConstraints;
- }
+ this.limitConstraints = policy.limitConstraints;
}
-
+
public String getId() {
return id;
}
this.matchParameters = matchParameters;
}
- public LinkedList<Constraint> getLimit_constraints() {
+ public List<Constraint> getLimit_constraints() {
return limitConstraints;
}
- public void setLimit_constraints(LinkedList<Constraint> limitConstraints) {
+ public void setLimit_constraints(List<Constraint> limitConstraints) {
this.limitConstraints = limitConstraints;
}
public boolean isValid() {
- return (id == null || name == null) ? false : true;
+ return (id != null && name != null);
}
-
+
@Override
public String toString() {
- return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", match_parameters="
+ return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", match_parameters="
+ matchParameters + ", limitConstraints=" + limitConstraints + "]";
}
return false;
}
GuardPolicy other = (GuardPolicy) obj;
- return equalsMayBeNull(description, other.description)
+ boolean isEq = equalsMayBeNull(description, other.description)
&& equalsMayBeNull(id, other.id)
- && equalsMayBeNull(name, other.name)
+ && equalsMayBeNull(name, other.name);
+ return isEq
&& equalsMayBeNull(limitConstraints, other.limitConstraints)
&& equalsMayBeNull(matchParameters, other.matchParameters);
}
-
+
private boolean equalsMayBeNull(final Object obj1, final Object obj2) {
if ( obj1 == null ) {
return obj2 == null;
}
return obj1.equals(obj2);
- }
+ }
}