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.plugins.persistence.jpa.hibernate;
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.AxConcept;
32 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
33 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
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 = -2962570563281067895L;
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;
62 public AxArtifactKey getKey() {
66 public List<AxKey> getKeys() {
67 return Arrays.asList((AxKey) getKey());
70 public void setKey(final AxArtifactKey key) {
74 public boolean checkSetKey() {
75 return (this.key != null);
78 public double getDoubleValue() {
82 public void setDoubleValue(final double doubleValue) {
83 this.doubleValue = doubleValue;
87 public AxValidationResult validate(final AxValidationResult result) {
88 return key.validate(result);
97 public String toString() {
98 return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
102 public AxConcept copyTo(final AxConcept target) {
103 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
104 if (copyObject instanceof ArtifactKeyTestEntity) {
105 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
106 if (this.checkSetKey()) {
107 copy.setKey(new AxArtifactKey(key));
111 copy.doubleValue = doubleValue;
119 public int hashCode() {
120 final int prime = 31;
122 result = prime * result + ((key == null) ? 0 : key.hashCode());
127 public boolean equals(final Object obj) {
132 if (getClass() != obj.getClass())
134 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
136 if (other.key != null)
138 } else if (!key.equals(other.key))
140 if (doubleValue != other.doubleValue)
146 public int compareTo(final AxConcept otherObj) {
147 if (otherObj == null)
149 if (this == otherObj)
151 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
153 if (other.key != null)
155 } else if (!key.equals(other.key))
156 return key.compareTo(other.key);
157 if (doubleValue != other.doubleValue)
158 return new Double(doubleValue).compareTo(other.doubleValue);