2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019 Nordix Foundation.
5 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.apex.testsuites.integration.context.entities;
25 import java.util.Arrays;
26 import java.util.List;
27 import javax.persistence.EmbeddedId;
28 import javax.persistence.Entity;
29 import javax.persistence.Table;
30 import javax.xml.bind.annotation.XmlElement;
31 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
32 import lombok.AllArgsConstructor;
33 import lombok.EqualsAndHashCode;
36 import lombok.ToString;
37 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
38 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
39 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
40 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
41 import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
44 * The Class ReferenceKeyTestEntity provides a reference key test concept.
47 @Table(name = "ReferenceKeyTestEntity")
51 @EqualsAndHashCode(callSuper = false)
53 public class ReferenceKeyTestEntity extends AxConcept {
54 private static final long serialVersionUID = -2962570563281067895L;
57 @XmlElement(name = "key", required = true)
58 @XmlJavaTypeAdapter(AxReferenceKeyAdapter.class)
59 protected AxReferenceKey key;
61 private double doubleValue;
64 * Instantiates a new reference key test entity.
66 public ReferenceKeyTestEntity() {
67 this.key = new AxReferenceKey();
72 * Instantiates a new reference key test entity.
74 * @param doubleValue the double value
76 public ReferenceKeyTestEntity(final Double doubleValue) {
77 this.key = new AxReferenceKey();
78 this.doubleValue = doubleValue;
85 public List<AxKey> getKeys() {
86 return Arrays.asList((AxKey) getKey());
92 * @return true, if successful
94 public boolean checkSetKey() {
95 return (this.key != null);
102 public AxValidationResult validate(final AxValidationResult result) {
103 return key.validate(result);
110 public void clean() {
118 public AxConcept copyTo(final AxConcept target) {
119 final Object copyObject = ((target == null) ? new ReferenceKeyTestEntity() : target);
120 if (copyObject instanceof ReferenceKeyTestEntity) {
121 final ReferenceKeyTestEntity copy = ((ReferenceKeyTestEntity) copyObject);
122 if (this.checkSetKey()) {
123 copy.setKey(new AxReferenceKey(key));
127 copy.doubleValue = doubleValue;
138 public int compareTo(final AxConcept otherObj) {
139 if (otherObj == null) {
142 if (this == otherObj) {
145 if (getClass() != otherObj.getClass()) {
148 final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) otherObj;
150 if (other.key != null) {
153 } else if (!key.equals(other.key)) {
154 return key.compareTo(other.key);
156 return Double.compare(doubleValue, other.doubleValue);