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;
27 import javax.persistence.EmbeddedId;
28 import javax.persistence.Entity;
29 import javax.persistence.Table;
30 import javax.xml.bind.annotation.XmlElement;
32 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
33 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
34 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
35 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
38 * The Class ArtifactKeyTestEntity is an entity for testing artifact keys.
41 @Table(name = "ArtifactKeyTestEntity")
42 public class ArtifactKeyTestEntity extends AxConcept {
43 private static final long serialVersionUID = -2962570563281067896L;
46 @XmlElement(name = "key", required = true)
47 protected AxArtifactKey key;
49 private double doubleValue;
52 * Instantiates a new artifact key test entity.
54 public ArtifactKeyTestEntity() {
55 this.key = new AxArtifactKey();
60 * Instantiates a new artifact key test entity.
62 * @param doubleValue the double value
64 public ArtifactKeyTestEntity(final Double doubleValue) {
65 this.key = new AxArtifactKey();
66 this.doubleValue = doubleValue;
70 * Instantiates a new artifact key test entity.
73 * @param doubleValue the double value
75 public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) {
77 this.doubleValue = doubleValue;
83 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
86 public AxArtifactKey getKey() {
93 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
96 public List<AxKey> getKeys() {
97 return Arrays.asList((AxKey) getKey());
103 * @param key the new key
105 public void setKey(final AxArtifactKey key) {
112 * @return true, if successful
114 public boolean checkSetKey() {
115 return (this.key != null);
119 * Gets the double value.
121 * @return the double value
123 public double getDoubleValue() {
128 * Sets the double value.
130 * @param doubleValue the new double value
132 public void setDoubleValue(final double doubleValue) {
133 this.doubleValue = doubleValue;
140 * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
141 * AxValidationResult)
144 public AxValidationResult validate(final AxValidationResult result) {
145 return key.validate(result);
151 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
154 public void clean() {
161 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
164 public String toString() {
165 return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
172 * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
176 public AxConcept copyTo(final AxConcept target) {
177 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
178 if (copyObject instanceof ArtifactKeyTestEntity) {
179 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
180 if (this.checkSetKey()) {
181 copy.setKey(new AxArtifactKey(key));
185 copy.doubleValue = doubleValue;
195 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
198 public int hashCode() {
199 final int prime = 31;
201 result = prime * result + ((key == null) ? 0 : key.hashCode());
208 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang.Object)
211 public boolean equals(final Object obj) {
218 if (getClass() != obj.getClass()) {
221 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
223 if (other.key != null) {
226 } else if (!key.equals(other.key)) {
229 return (Double.compare(doubleValue, other.doubleValue) == 0);
235 * @see java.lang.Comparable#compareTo(java.lang.Object)
238 public int compareTo(final AxConcept otherObj) {
239 if (otherObj == null) {
242 if (this == otherObj) {
245 if (getClass() != otherObj.getClass()) {
248 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
250 if (other.key != null) {
253 } else if (!key.equals(other.key)) {
254 return key.compareTo(other.key);
256 return Double.compare(doubleValue, other.doubleValue);