2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019 Nordix Foundation.
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.testsuites.integration.context.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 org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
31 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
32 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
33 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
36 * The Class ArtifactKeyTestEntity is an entity for testing artifact keys.
39 @Table(name = "ArtifactKeyTestEntity")
40 public class ArtifactKeyTestEntity extends AxConcept {
41 private static final long serialVersionUID = -2962570563281067896L;
44 @XmlElement(name = "key", required = true)
45 protected AxArtifactKey key;
47 private double doubleValue;
50 * Instantiates a new artifact key test entity.
52 public ArtifactKeyTestEntity() {
53 this.key = new AxArtifactKey();
58 * Instantiates a new artifact key test entity.
60 * @param doubleValue the double value
62 public ArtifactKeyTestEntity(final Double doubleValue) {
63 this.key = new AxArtifactKey();
64 this.doubleValue = doubleValue;
68 * Instantiates a new artifact key test entity.
71 * @param doubleValue the double value
73 public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) {
75 this.doubleValue = doubleValue;
82 public AxArtifactKey getKey() {
90 public List<AxKey> getKeys() {
91 return Arrays.asList((AxKey) getKey());
97 * @param key the new key
99 public void setKey(final AxArtifactKey key) {
106 * @return true, if successful
108 public boolean checkSetKey() {
109 return (this.key != null);
113 * Gets the double value.
115 * @return the double value
117 public double getDoubleValue() {
122 * Sets the double value.
124 * @param doubleValue the new double value
126 public void setDoubleValue(final double doubleValue) {
127 this.doubleValue = doubleValue;
134 public AxValidationResult validate(final AxValidationResult result) {
135 return key.validate(result);
142 public void clean() {
150 public String toString() {
151 return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
158 public AxConcept copyTo(final AxConcept target) {
159 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
160 if (copyObject instanceof ArtifactKeyTestEntity) {
161 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
162 if (this.checkSetKey()) {
163 copy.setKey(new AxArtifactKey(key));
167 copy.doubleValue = doubleValue;
178 public int hashCode() {
179 final int prime = 31;
181 result = prime * result + ((key == null) ? 0 : key.hashCode());
189 public boolean equals(final Object obj) {
196 if (getClass() != obj.getClass()) {
199 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
201 if (other.key != null) {
204 } else if (!key.equals(other.key)) {
207 return (Double.compare(doubleValue, other.doubleValue) == 0);
214 public int compareTo(final AxConcept otherObj) {
215 if (otherObj == null) {
218 if (this == otherObj) {
221 if (getClass() != otherObj.getClass()) {
224 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
226 if (other.key != null) {
229 } else if (!key.equals(other.key)) {
230 return key.compareTo(other.key);
232 return Double.compare(doubleValue, other.doubleValue);