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 lombok.EqualsAndHashCode;
33 import lombok.ToString;
34 import org.apache.commons.lang3.builder.CompareToBuilder;
35 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
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.AxValidationResult;
41 * The Class ArtifactKeyTestEntity is an entity for testing artifact keys.
44 @Table(name = "ArtifactKeyTestEntity")
48 @EqualsAndHashCode(callSuper = false)
49 public class ArtifactKeyTestEntity extends AxConcept {
50 private static final long serialVersionUID = -2962570563281067896L;
53 @XmlElement(name = "key", required = true)
54 protected AxArtifactKey key;
56 private double doubleValue;
59 * Instantiates a new artifact key test entity.
61 public ArtifactKeyTestEntity() {
62 this.key = new AxArtifactKey();
67 * Instantiates a new artifact key test entity.
69 * @param doubleValue the double value
71 public ArtifactKeyTestEntity(final Double doubleValue) {
72 this.key = new AxArtifactKey();
73 this.doubleValue = doubleValue;
77 * Instantiates a new artifact key test entity.
80 * @param doubleValue the double value
82 public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) {
84 this.doubleValue = doubleValue;
91 public List<AxKey> getKeys() {
92 return Arrays.asList((AxKey) getKey());
98 * @return true, if successful
100 public boolean checkSetKey() {
101 return (this.key != null);
108 public AxValidationResult validate(final AxValidationResult result) {
109 return key.validate(result);
116 public void clean() {
124 public AxConcept copyTo(final AxConcept target) {
125 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
126 if (copyObject instanceof ArtifactKeyTestEntity) {
127 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
128 if (this.checkSetKey()) {
129 copy.setKey(new AxArtifactKey(key));
133 copy.doubleValue = doubleValue;
144 public int compareTo(final AxConcept otherObj) {
145 if (otherObj == null) {
148 if (this == otherObj) {
151 if (getClass() != otherObj.getClass()) {
154 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
155 return new CompareToBuilder()
156 .append(key, other.key)
157 .append(doubleValue, other.doubleValue)