* ============LICENSE_START=======================================================
* ONAP Policy Model
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.models.tosca.simple.concepts;
+import jakarta.persistence.Column;
+import jakarta.persistence.EmbeddedId;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Inheritance;
+import jakarta.persistence.InheritanceType;
+import jakarta.persistence.Table;
+import java.io.Serial;
import java.util.List;
-
-import javax.persistence.Column;
-import javax.persistence.EmbeddedId;
-import javax.persistence.Entity;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Table;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
-
import org.apache.commons.lang3.ObjectUtils;
-import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfKey;
import org.onap.policy.models.base.PfReferenceKey;
-import org.onap.policy.models.base.PfValidationMessage;
-import org.onap.policy.models.base.PfValidationResult;
-import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+import org.onap.policy.models.base.validation.annotations.VerifyKey;
/**
* Class to represent the EventFilter in TOSCA definition.
@Data
@EqualsAndHashCode(callSuper = false)
public class JpaToscaEventFilter extends PfConcept {
+ @Serial
private static final long serialVersionUID = 8769020537228210247L;
@EmbeddedId
+ @VerifyKey
+ @NotNull
private PfReferenceKey key;
@Column
+ @VerifyKey
+ @NotNull
private PfConceptKey node;
@Column
+ @NotBlank
private String requirement;
@Column
+ @NotBlank
private String capability;
/**
*/
public JpaToscaEventFilter(final JpaToscaEventFilter copyConcept) {
super(copyConcept);
+ this.key = new PfReferenceKey(copyConcept.key);
+ this.node = new PfConceptKey(copyConcept.node);
+ this.requirement = copyConcept.requirement;
+ this.capability = copyConcept.capability;
}
@Override
capability = (capability != null ? capability.trim() : capability);
}
- @Override
- public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
- PfValidationResult result = resultIn;
-
- if (key.isNullKey()) {
- result.addValidationMessage(
- new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
- }
-
- result = key.validate(result);
-
- if (node == null || node.isNullKey()) {
- result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "node on an event filter may not be null"));
- }
-
- if (requirement != null && requirement.trim().length() == 0) {
- result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "event filter requirement may not be blank"));
- }
-
- if (capability != null && capability.trim().length() == 0) {
- result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "event filter capability may not be blank"));
- }
-
- return result;
- }
-
@Override
public int compareTo(final PfConcept otherConcept) {
if (otherConcept == null) {
return 0;
}
if (getClass() != otherConcept.getClass()) {
- return this.hashCode() - otherConcept.hashCode();
+ return getClass().getName().compareTo(otherConcept.getClass().getName());
}
final JpaToscaEventFilter other = (JpaToscaEventFilter) otherConcept;
- if (!key.equals(other.key)) {
- return key.compareTo(other.key);
+ int result = key.compareTo(other.key);
+ if (result != 0) {
+ return result;
}
- if (!node.equals(other.node)) {
- return node.compareTo(other.node);
+ result = node.compareTo(other.node);
+ if (result != 0) {
+ return result;
}
- int result = ObjectUtils.compare(requirement, other.requirement);
+ result = ObjectUtils.compare(requirement, other.requirement);
if (result != 0) {
return result;
}
return ObjectUtils.compare(capability, other.capability);
}
-
- @Override
- public PfConcept copyTo(@NonNull final PfConcept target) {
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, JpaToscaEventFilter.class);
-
- final JpaToscaEventFilter copy = ((JpaToscaEventFilter) copyObject);
- copy.setKey(new PfReferenceKey(key));
- copy.setNode(new PfConceptKey(node));
- copy.setRequirement(requirement);
- copy.setCapability(capability);
-
- return copy;
- }
-}
\ No newline at end of file
+}