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 lombok.AllArgsConstructor;
32 import lombok.EqualsAndHashCode;
35 import lombok.ToString;
36 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
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.AxValidationResult;
42 * The Class ArtifactKeyTestEntity is an entity for testing artifact keys.
45 @Table(name = "ArtifactKeyTestEntity")
49 @EqualsAndHashCode(callSuper = false)
51 public class ArtifactKeyTestEntity extends AxConcept {
52 private static final long serialVersionUID = -2962570563281067896L;
55 @XmlElement(name = "key", required = true)
56 protected AxArtifactKey key;
58 private double doubleValue;
61 * Instantiates a new artifact key test entity.
63 public ArtifactKeyTestEntity() {
64 this.key = new AxArtifactKey();
69 * Instantiates a new artifact key test entity.
71 * @param doubleValue the double value
73 public ArtifactKeyTestEntity(final Double doubleValue) {
74 this.key = new AxArtifactKey();
75 this.doubleValue = doubleValue;
82 public List<AxKey> getKeys() {
83 return Arrays.asList((AxKey) getKey());
89 * @return true, if successful
91 public boolean checkSetKey() {
92 return (this.key != null);
99 public AxValidationResult validate(final AxValidationResult result) {
100 return key.validate(result);
107 public void clean() {
115 public AxConcept copyTo(final AxConcept target) {
116 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
117 if (copyObject instanceof ArtifactKeyTestEntity) {
118 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
119 if (this.checkSetKey()) {
120 copy.setKey(new AxArtifactKey(key));
124 copy.doubleValue = doubleValue;
135 public int compareTo(final AxConcept otherObj) {
136 if (otherObj == null) {
139 if (this == otherObj) {
142 if (getClass() != otherObj.getClass()) {
145 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
147 if (other.key != null) {
150 } else if (!key.equals(other.key)) {
151 return key.compareTo(other.key);
153 return Double.compare(doubleValue, other.doubleValue);