2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Modifications Copyright (C) 2021 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.apex.plugins.persistence.jpa.eclipselink.entities;
24 import java.util.Arrays;
25 import java.util.List;
26 import javax.persistence.EmbeddedId;
27 import javax.persistence.Entity;
28 import javax.persistence.Table;
29 import javax.xml.bind.annotation.XmlElement;
30 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
31 import lombok.EqualsAndHashCode;
34 import lombok.ToString;
35 import org.apache.commons.lang3.builder.CompareToBuilder;
36 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
37 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
38 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
39 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
40 import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
43 * The Class ReferenceKeyTestEntity provides a reference key test concept.
46 @Table(name = "ReferenceKeyTestEntity")
50 @EqualsAndHashCode(callSuper = false)
51 public class ReferenceKeyTestEntity extends AxConcept {
52 private static final long serialVersionUID = -2962570563281067895L;
55 @XmlElement(name = "key", required = true)
56 @XmlJavaTypeAdapter(AxReferenceKeyAdapter.class)
57 protected AxReferenceKey key;
59 private double doubleValue;
62 * Instantiates a new reference key test entity.
64 public ReferenceKeyTestEntity() {
65 this.key = new AxReferenceKey();
70 * Instantiates a new reference key test entity.
72 * @param doubleValue the double value
74 public ReferenceKeyTestEntity(final Double doubleValue) {
75 this.key = new AxReferenceKey();
76 this.doubleValue = doubleValue;
80 * Instantiates a new reference key test entity.
83 * @param doubleValue the double value
85 public ReferenceKeyTestEntity(final AxReferenceKey key, final Double doubleValue) {
87 this.doubleValue = doubleValue;
94 public List<AxKey> getKeys() {
95 return Arrays.asList((AxKey) getKey());
101 * @return true, if successful
103 public boolean checkSetKey() {
104 return (this.key != null);
111 public AxValidationResult validate(final AxValidationResult result) {
112 return key.validate(result);
119 public void clean() {
127 public AxConcept copyTo(final AxConcept target) {
128 final Object copyObject = ((target == null) ? new ReferenceKeyTestEntity() : target);
129 if (copyObject instanceof ReferenceKeyTestEntity) {
130 final ReferenceKeyTestEntity copy = ((ReferenceKeyTestEntity) copyObject);
131 if (this.checkSetKey()) {
132 copy.setKey(new AxReferenceKey(key));
136 copy.doubleValue = doubleValue;
147 public int compareTo(final AxConcept otherObj) {
148 if (otherObj == null) {
151 if (this == otherObj) {
154 if (getClass() != otherObj.getClass()) {
157 final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) otherObj;
158 return new CompareToBuilder()
159 .append(key, other.key)
160 .append(doubleValue, other.doubleValue)