2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020, 2023 Nordix Foundation.
4 * Modifications Copyright (C) 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;
32 import lombok.EqualsAndHashCode;
33 import lombok.NonNull;
34 import org.onap.policy.common.parameters.BeanValidationResult;
35 import org.onap.policy.models.base.PfConcept;
36 import org.onap.policy.models.base.PfKey;
37 import org.onap.policy.models.base.PfTimestampKey;
40 @Table(name = "DummyTimestampEntity")
42 @EqualsAndHashCode(callSuper = false)
43 public class DummyTimestampEntity extends PfConcept {
45 private static final long serialVersionUID = -2962570563281067895L;
49 private PfTimestampKey key;
52 private double doubleValue;
55 * Default constructor.
57 public DummyTimestampEntity() {
58 this.key = new PfTimestampKey();
59 this.doubleValue = 123.45;
62 public DummyTimestampEntity(DummyTimestampEntity source) {
63 this.key = source.key;
64 this.doubleValue = source.doubleValue;
71 * @param doubleValue the double value
73 public DummyTimestampEntity(final PfTimestampKey key, final double doubleValue) {
75 this.doubleValue = doubleValue;
79 public List<PfKey> getKeys() {
80 final List<PfKey> keyList = new ArrayList<>();
81 keyList.add(getKey());
86 public BeanValidationResult validate(@NonNull String fieldName) {
87 BeanValidationResult result = new BeanValidationResult(fieldName, this);
88 result.addResult(key.validate("key"));
98 public int compareTo(@NonNull final PfConcept otherObj) {
99 if (this == otherObj) {
102 if (getClass() != otherObj.getClass()) {
103 return this.getClass().getName().compareTo(otherObj.getClass().getName());
106 final DummyTimestampEntity other = (DummyTimestampEntity) otherObj;
108 return Double.compare(doubleValue, other.doubleValue);