2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
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.context.test.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 @Table(name = "ArtifactKeyTestEntity")
38 public class ArtifactKeyTestEntity extends AxConcept {
39 private static final long serialVersionUID = -2962570563281067896L;
42 @XmlElement(name = "key", required = true)
43 protected AxArtifactKey key;
45 private double doubleValue;
47 public ArtifactKeyTestEntity() {
48 this.key = new AxArtifactKey();
52 public ArtifactKeyTestEntity(final Double doubleValue) {
53 this.key = new AxArtifactKey();
54 this.doubleValue = doubleValue;
57 public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) {
59 this.doubleValue = doubleValue;
63 public AxArtifactKey getKey() {
68 public List<AxKey> getKeys() {
69 return Arrays.asList((AxKey) getKey());
72 public void setKey(final AxArtifactKey key) {
76 public boolean checkSetKey() {
77 return (this.key != null);
80 public double getDoubleValue() {
84 public void setDoubleValue(final double doubleValue) {
85 this.doubleValue = doubleValue;
89 public AxValidationResult validate(final AxValidationResult result) {
90 return key.validate(result);
99 public String toString() {
100 return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
104 public AxConcept copyTo(final AxConcept target) {
105 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
106 if (copyObject instanceof ArtifactKeyTestEntity) {
107 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
108 if (this.checkSetKey()) {
109 copy.setKey(new AxArtifactKey(key));
113 copy.doubleValue = doubleValue;
121 public int hashCode() {
122 final int prime = 31;
124 result = prime * result + ((key == null) ? 0 : key.hashCode());
129 public boolean equals(final Object obj) {
136 if (getClass() != obj.getClass()) {
139 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
141 if (other.key != null) {
144 } else if (!key.equals(other.key)) {
147 return (Double.compare(doubleValue, other.doubleValue) == 0);
151 public int compareTo(final AxConcept otherObj) {
152 if (otherObj == null) {
155 if (this == otherObj) {
158 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
160 if (other.key != null) {
163 } else if (!key.equals(other.key)) {
164 return key.compareTo(other.key);
166 return Double.compare(doubleValue, other.doubleValue);