2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Modifications Copyright (C) 2019 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 java.util.ArrayList;
25 import java.util.List;
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.PfKey;
39 import org.onap.policy.models.base.PfReferenceKey;
40 import org.onap.policy.models.base.PfValidationResult;
43 @Table(name = "DummyReferenceEntity")
45 @EqualsAndHashCode(callSuper = false)
46 public class DummyReferenceEntity extends PfConcept {
47 private static final long serialVersionUID = -2962570563281067894L;
51 private PfReferenceKey key;
54 private double doubleValue;
57 * Default constructor.
59 public DummyReferenceEntity() {
60 this.key = new PfReferenceKey();
61 this.doubleValue = 123.45;
64 public DummyReferenceEntity(DummyReferenceEntity source) {
65 this.key = source.key;
66 this.doubleValue = source.doubleValue;
73 * @param doubleValue the double value
75 public DummyReferenceEntity(final PfReferenceKey key, final double doubleValue) {
77 this.doubleValue = doubleValue;
81 public List<PfKey> getKeys() {
82 final List<PfKey> keyList = new ArrayList<>();
83 keyList.add(getKey());
88 public PfValidationResult validate(final PfValidationResult result) {
89 return key.validate(result);
99 public int compareTo(final PfConcept otherObj) {
100 Assertions.argumentNotNull(otherObj, "comparison object may not be null");
102 if (this == otherObj) {
105 if (getClass() != otherObj.getClass()) {
106 return this.hashCode() - otherObj.hashCode();
109 final DummyReferenceEntity other = (DummyReferenceEntity) otherObj;
111 return Double.compare(doubleValue, other.doubleValue);