2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.dao;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.UUID;
27 import javax.persistence.Column;
28 import javax.persistence.EmbeddedId;
29 import javax.persistence.Entity;
30 import javax.persistence.Table;
33 import lombok.EqualsAndHashCode;
34 import lombok.NonNull;
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;
40 import org.onap.policy.models.base.PfValidationResult;
43 @Table(name = "DummyConceptEntity")
45 @EqualsAndHashCode(callSuper = false)
46 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();
65 public DummyConceptEntity(final Double doubleValue) {
66 this.key = new PfConceptKey();
69 public DummyConceptEntity(final PfConceptKey key, final Double doubleValue) {
77 * @param uuid the uuid
78 * @param description the description
80 public DummyConceptEntity(PfConceptKey key, UUID uuid, String description) {
83 this.description = description;
87 public List<PfKey> getKeys() {
88 final List<PfKey> keyList = new ArrayList<>();
89 keyList.add(getKey());
94 public PfValidationResult validate(final PfValidationResult result) {
95 return key.validate(result);
104 public PfConcept copyTo(final PfConcept target) {
105 Assertions.argumentNotNull(target, "target may not be null");
107 final PfConcept copyObject = target;
108 Assertions.instanceOf(copyObject, DummyConceptEntity.class);
110 final DummyConceptEntity copy = ((DummyConceptEntity) copyObject);
113 copy.setDescription(description);
119 public int compareTo(final PfConcept otherObj) {
120 Assertions.argumentNotNull(otherObj, "comparison object may not be null");
122 if (this == otherObj) {
125 if (getClass() != otherObj.getClass()) {
126 return this.hashCode() - otherObj.hashCode();
129 final DummyConceptEntity other = (DummyConceptEntity) otherObj;
131 if (!key.equals(other.key)) {
132 return key.compareTo(other.key);
134 if (!uuid.equals(other.uuid)) {
135 return uuid.compareTo(other.uuid);
137 return description.compareTo(other.description);