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;
84 public AxArtifactKey getKey() {
92 public List<AxKey> getKeys() {
93 return Arrays.asList((AxKey) getKey());
99 * @param key the new key
101 public void setKey(final AxArtifactKey key) {
108 * @return true, if successful
110 public boolean checkSetKey() {
111 return (this.key != null);
115 * Gets the double value.
117 * @return the double value
119 public double getDoubleValue() {
124 * Sets the double value.
126 * @param doubleValue the new double value
128 public void setDoubleValue(final double doubleValue) {
129 this.doubleValue = doubleValue;
136 public AxValidationResult validate(final AxValidationResult result) {
137 return key.validate(result);
144 public void clean() {
152 public String toString() {
153 return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
160 public AxConcept copyTo(final AxConcept target) {
161 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
162 if (copyObject instanceof ArtifactKeyTestEntity) {
163 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
164 if (this.checkSetKey()) {
165 copy.setKey(new AxArtifactKey(key));
169 copy.doubleValue = doubleValue;
180 public int hashCode() {
181 final int prime = 31;
183 result = prime * result + ((key == null) ? 0 : key.hashCode());
191 public boolean equals(final Object obj) {
198 if (getClass() != obj.getClass()) {
201 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
203 if (other.key != null) {
206 } else if (!key.equals(other.key)) {
209 return (Double.compare(doubleValue, other.doubleValue) == 0);
216 public int compareTo(final AxConcept otherObj) {
217 if (otherObj == null) {
220 if (this == otherObj) {
223 if (getClass() != otherObj.getClass()) {
226 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
228 if (other.key != null) {
231 } else if (!key.equals(other.key)) {
232 return key.compareTo(other.key);
234 return Double.compare(doubleValue, other.doubleValue);