2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
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.models.base.testconcepts;
24 import java.util.List;
25 import javax.persistence.EmbeddedId;
27 import lombok.EqualsAndHashCode;
28 import lombok.NonNull;
29 import org.apache.commons.lang3.ObjectUtils;
30 import org.onap.policy.common.parameters.annotations.NotBlank;
31 import org.onap.policy.common.parameters.annotations.NotNull;
32 import org.onap.policy.models.base.PfAuthorative;
33 import org.onap.policy.models.base.PfConcept;
34 import org.onap.policy.models.base.PfConceptKey;
35 import org.onap.policy.models.base.PfKey;
36 import org.onap.policy.models.base.validation.annotations.VerifyKey;
39 @EqualsAndHashCode(callSuper = false)
40 public class DummyPfConcept extends PfConcept implements PfAuthorative<DummyAuthorativeConcept> {
41 private static final long serialVersionUID = 1L;
46 private PfConceptKey key;
49 private String description;
53 * The Default Constructor creates a {@link DummyPfConcept} object with a null key.
55 public DummyPfConcept() {
56 this(new PfConceptKey());
60 * The Key Constructor creates a {@link DummyPfConcept} object with the given concept key.
64 public DummyPfConcept(@NonNull final PfConceptKey key) {
71 * @param copyConcept the concept to copy from
73 public DummyPfConcept(final DummyPfConcept copyConcept) {
75 this.key = new PfConceptKey(copyConcept.key);
76 this.description = copyConcept.description;
80 public DummyAuthorativeConcept toAuthorative() {
81 DummyAuthorativeConcept dac = new DummyAuthorativeConcept();
82 dac.setName(key.getName());
83 dac.setVersion(key.getVersion());
84 dac.setDescription(description);
90 public void fromAuthorative(DummyAuthorativeConcept dac) {
91 key.setName(dac.getName());
92 key.setVersion(dac.getVersion());
93 description = dac.getDescription();
97 public List<PfKey> getKeys() {
98 return getKey().getKeys();
102 public void clean() {
105 description = (description != null ? description.trim() : null);
109 public int compareTo(final PfConcept otherConcept) {
110 if (otherConcept == null) {
113 if (this == otherConcept) {
116 if (getClass() != otherConcept.getClass()) {
117 return this.hashCode() - otherConcept.hashCode();
120 final DummyPfConcept other = (DummyPfConcept) otherConcept;
121 if (!key.equals(other.key)) {
122 return key.compareTo(other.key);
125 return ObjectUtils.compare(description, other.description);