import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Lob;
import javax.persistence.Table;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
-
import org.apache.commons.collections4.CollectionUtils;
import org.onap.policy.models.base.PfAuthorative;
import org.onap.policy.models.base.PfConcept;
super.setToscaEntity(toscaPolicyType);
super.toAuthorative();
- if (properties != null) {
- Map<String, ToscaProperty> propertyMap = new LinkedHashMap<>();
-
- for (Entry<String, JpaToscaProperty> entry : properties.entrySet()) {
- propertyMap.put(entry.getKey(), entry.getValue().toAuthorative());
- }
-
- toscaPolicyType.setProperties(propertyMap);
- }
+ toscaPolicyType.setProperties(PfUtils.mapMap(properties, JpaToscaProperty::toAuthorative));
return toscaPolicyType;
}
public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
PfValidationResult result = super.validate(resultIn);
+ if (PfKey.NULL_KEY_VERSION.equals(getKey().getVersion())) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "key version is a null version"));
+ }
+
if (properties != null) {
result = validateProperties(result);
}
}
final JpaToscaPolicyType other = (JpaToscaPolicyType) otherConcept;
- if (!super.equals(other)) {
- return super.compareTo(other);
+ int result = super.compareTo(other);
+ if (result != 0) {
+ return result;
}
- int retVal = PfUtils.compareObjects(properties, other.properties);
- if (retVal != 0) {
- return retVal;
+ result = PfUtils.compareMaps(properties, other.properties);
+ if (result != 0) {
+ return result;
}
- retVal = PfUtils.compareObjects(targets, other.targets);
- if (retVal != 0) {
- return retVal;
+ result = PfUtils.compareCollections(targets, other.targets);
+ if (result != 0) {
+ return result;
}
- return PfUtils.compareObjects(triggers, other.triggers);
+ return PfUtils.compareCollections(triggers, other.triggers);
}
/**