2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * SPDX-License-Identifier: Apache-2.0
21 * ============LICENSE_END=========================================================
24 package org.onap.policy.models.tosca.simple.concepts;
26 import jakarta.persistence.Column;
27 import jakarta.persistence.EmbeddedId;
28 import jakarta.persistence.Entity;
29 import jakarta.persistence.Inheritance;
30 import jakarta.persistence.InheritanceType;
31 import jakarta.persistence.Table;
32 import java.io.Serial;
33 import java.util.List;
35 import lombok.EqualsAndHashCode;
36 import lombok.NonNull;
37 import org.apache.commons.lang3.ObjectUtils;
38 import org.onap.policy.common.parameters.annotations.NotBlank;
39 import org.onap.policy.common.parameters.annotations.NotNull;
40 import org.onap.policy.models.base.PfConcept;
41 import org.onap.policy.models.base.PfConceptKey;
42 import org.onap.policy.models.base.PfKey;
43 import org.onap.policy.models.base.PfReferenceKey;
44 import org.onap.policy.models.base.validation.annotations.VerifyKey;
47 * Class to represent the EventFilter in TOSCA definition.
49 * @author Chenfei Gao (cgao@research.att.com)
50 * @author Liam Fallon (liam.fallon@est.tech)
53 @Table(name = "ToscaEventFilter")
54 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
56 @EqualsAndHashCode(callSuper = false)
57 public class JpaToscaEventFilter extends PfConcept {
59 private static final long serialVersionUID = 8769020537228210247L;
64 private PfReferenceKey key;
69 private PfConceptKey node;
73 private String requirement;
77 private String capability;
80 * The Default Constructor creates a {@link JpaToscaEventFilter} object with a null key.
82 public JpaToscaEventFilter() {
83 this(new PfReferenceKey());
87 * The Key Constructor creates a {@link JpaToscaEventFilter} object with the given concept key.
91 public JpaToscaEventFilter(@NonNull final PfReferenceKey key) {
92 this(key, new PfConceptKey());
96 * The full Constructor creates a {@link JpaToscaEventFilter} object with the given concept key and node.
100 public JpaToscaEventFilter(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey node) {
108 * @param copyConcept the concept to copy from
110 public JpaToscaEventFilter(final JpaToscaEventFilter copyConcept) {
112 this.key = new PfReferenceKey(copyConcept.key);
113 this.node = new PfConceptKey(copyConcept.node);
114 this.requirement = copyConcept.requirement;
115 this.capability = copyConcept.capability;
119 public List<PfKey> getKeys() {
120 final List<PfKey> keyList = getKey().getKeys();
121 keyList.addAll(node.getKeys());
126 public void clean() {
130 requirement = (requirement != null ? requirement.trim() : requirement);
131 capability = (capability != null ? capability.trim() : capability);
135 public int compareTo(final PfConcept otherConcept) {
136 if (otherConcept == null) {
139 if (this == otherConcept) {
142 if (getClass() != otherConcept.getClass()) {
143 return getClass().getName().compareTo(otherConcept.getClass().getName());
146 final JpaToscaEventFilter other = (JpaToscaEventFilter) otherConcept;
147 int result = key.compareTo(other.key);
152 result = node.compareTo(other.node);
157 result = ObjectUtils.compare(requirement, other.requirement);
162 return ObjectUtils.compare(capability, other.capability);