2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019, 2023 Nordix Foundation.
4 * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.dao;
24 import jakarta.persistence.Column;
25 import jakarta.persistence.EmbeddedId;
26 import jakarta.persistence.Entity;
27 import jakarta.persistence.Table;
28 import java.io.Serial;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.UUID;
33 import lombok.EqualsAndHashCode;
34 import lombok.NonNull;
35 import org.onap.policy.common.parameters.BeanValidationResult;
36 import org.onap.policy.common.utils.validation.Assertions;
37 import org.onap.policy.models.base.PfConcept;
38 import org.onap.policy.models.base.PfConceptKey;
39 import org.onap.policy.models.base.PfKey;
42 @Table(name = "DummyConceptEntity")
44 @EqualsAndHashCode(callSuper = false)
45 public class DummyConceptEntity extends PfConcept {
47 private static final long serialVersionUID = -2962570563281067894L;
51 private PfConceptKey key;
59 private String description;
61 public DummyConceptEntity() {
62 this.key = new PfConceptKey();
68 * @param source object from which to copy
70 public DummyConceptEntity(DummyConceptEntity source) {
71 this.key = source.key;
72 this.uuid = source.uuid;
73 this.description = source.description;
76 public DummyConceptEntity(final Double doubleValue) {
77 this.key = new PfConceptKey();
80 public DummyConceptEntity(final PfConceptKey key, final Double doubleValue) {
88 * @param uuid the uuid
89 * @param description the description
91 public DummyConceptEntity(PfConceptKey key, UUID uuid, String description) {
94 this.description = description;
98 public List<PfKey> getKeys() {
99 final List<PfKey> keyList = new ArrayList<>();
100 keyList.add(getKey());
105 public BeanValidationResult validate(@NonNull String fieldName) {
106 BeanValidationResult result = new BeanValidationResult(fieldName, this);
107 result.addResult(key.validate("key"));
112 public void clean() {
117 public int compareTo(final PfConcept otherObj) {
118 Assertions.argumentNotNull(otherObj, "comparison object may not be null");
120 if (this == otherObj) {
123 if (getClass() != otherObj.getClass()) {
124 return this.hashCode() - otherObj.hashCode();
127 final DummyConceptEntity other = (DummyConceptEntity) otherObj;
129 if (!key.equals(other.key)) {
130 return key.compareTo(other.key);
132 if (!uuid.equals(other.uuid)) {
133 return uuid.compareTo(other.uuid);
135 return description.compareTo(other.description);