2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities;
23 import java.util.Arrays;
24 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;
31 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
32 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
33 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
34 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
37 * The Class ArtifactKeyTestEntity is an entity for testing artifact keys.
40 @Table(name = "ArtifactKeyTestEntity")
41 public class ArtifactKeyTestEntity extends AxConcept {
42 private static final long serialVersionUID = -2962570563281067896L;
45 @XmlElement(name = "key", required = true)
46 protected AxArtifactKey key;
48 private double doubleValue;
51 * Instantiates a new artifact key test entity.
53 public ArtifactKeyTestEntity() {
54 this.key = new AxArtifactKey();
59 * Instantiates a new artifact key test entity.
61 * @param doubleValue the double value
63 public ArtifactKeyTestEntity(final Double doubleValue) {
64 this.key = new AxArtifactKey();
65 this.doubleValue = doubleValue;
69 * Instantiates a new artifact key test entity.
72 * @param doubleValue the double value
74 public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) {
76 this.doubleValue = doubleValue;
82 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
85 public AxArtifactKey getKey() {
92 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
95 public List<AxKey> getKeys() {
96 return Arrays.asList((AxKey) getKey());
102 * @param key the new key
104 public void setKey(final AxArtifactKey key) {
111 * @return true, if successful
113 public boolean checkSetKey() {
114 return (this.key != null);
118 * Gets the double value.
120 * @return the double value
122 public double getDoubleValue() {
127 * Sets the double value.
129 * @param doubleValue the new double value
131 public void setDoubleValue(final double doubleValue) {
132 this.doubleValue = doubleValue;
139 * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
140 * AxValidationResult)
143 public AxValidationResult validate(final AxValidationResult result) {
144 return key.validate(result);
150 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
153 public void clean() {
160 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
163 public String toString() {
164 return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
171 * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
175 public AxConcept copyTo(final AxConcept target) {
176 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
177 if (copyObject instanceof ArtifactKeyTestEntity) {
178 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
179 if (this.checkSetKey()) {
180 copy.setKey(new AxArtifactKey(key));
184 copy.doubleValue = doubleValue;
194 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
197 public int hashCode() {
198 final int prime = 31;
200 result = prime * result + ((key == null) ? 0 : key.hashCode());
207 * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang.Object)
210 public boolean equals(final Object obj) {
217 if (getClass() != obj.getClass()) {
220 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
222 if (other.key != null) {
225 } else if (!key.equals(other.key)) {
228 return (Double.compare(doubleValue, other.doubleValue) == 0);
234 * @see java.lang.Comparable#compareTo(java.lang.Object)
237 public int compareTo(final AxConcept otherObj) {
238 if (otherObj == null) {
241 if (this == otherObj) {
244 if (getClass() != otherObj.getClass()) {
247 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
249 if (other.key != null) {
252 } else if (!key.equals(other.key)) {
253 return key.compareTo(other.key);
255 return Double.compare(doubleValue, other.doubleValue);