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;
 
  83     public AxArtifactKey getKey() {
 
  91     public List<AxKey> getKeys() {
 
  92         return Arrays.asList((AxKey) getKey());
 
  98      * @param key the new key
 
 100     public void setKey(final AxArtifactKey key) {
 
 107      * @return true, if successful
 
 109     public boolean checkSetKey() {
 
 110         return (this.key != null);
 
 114      * Gets the double value.
 
 116      * @return the double value
 
 118     public double getDoubleValue() {
 
 123      * Sets the double value.
 
 125      * @param doubleValue the new double value
 
 127     public void setDoubleValue(final double doubleValue) {
 
 128         this.doubleValue = doubleValue;
 
 135     public AxValidationResult validate(final AxValidationResult result) {
 
 136         return key.validate(result);
 
 143     public void clean() {
 
 151     public String toString() {
 
 152         return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]";
 
 159     public AxConcept copyTo(final AxConcept target) {
 
 160         final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
 
 161         if (copyObject instanceof ArtifactKeyTestEntity) {
 
 162             final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
 
 163             if (this.checkSetKey()) {
 
 164                 copy.setKey(new AxArtifactKey(key));
 
 168             copy.doubleValue = doubleValue;
 
 179     public int hashCode() {
 
 180         final int prime = 31;
 
 182         result = prime * result + ((key == null) ? 0 : key.hashCode());
 
 190     public boolean equals(final Object obj) {
 
 197         if (getClass() != obj.getClass()) {
 
 200         final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj;
 
 202             if (other.key != null) {
 
 205         } else if (!key.equals(other.key)) {
 
 208         return (Double.compare(doubleValue, other.doubleValue) == 0);
 
 215     public int compareTo(final AxConcept otherObj) {
 
 216         if (otherObj == null) {
 
 219         if (this == otherObj) {
 
 222         if (getClass() != otherObj.getClass()) {
 
 225         final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
 
 227             if (other.key != null) {
 
 230         } else if (!key.equals(other.key)) {
 
 231             return key.compareTo(other.key);
 
 233         return Double.compare(doubleValue, other.doubleValue);