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.ArrayList;
25 import java.util.List;
27 import lombok.EqualsAndHashCode;
28 import lombok.NonNull;
29 import org.onap.policy.common.parameters.BeanValidationResult;
30 import org.onap.policy.models.base.PfConcept;
31 import org.onap.policy.models.base.PfConceptKey;
32 import org.onap.policy.models.base.PfKey;
33 import org.onap.policy.models.base.PfModel;
34 import org.onap.policy.models.base.PfUtils;
37 @EqualsAndHashCode(callSuper = true)
38 public class DummyPfModel extends PfModel {
39 private static final long serialVersionUID = 8800599637708309945L;
41 private List<PfKey> keyList;
44 * The Default Constructor creates a {@link DummyPfModel} object with a null concept key and
45 * creates an empty TOSCA model.
47 public DummyPfModel() {
49 super.setKey(new PfConceptKey());
50 this.keyList = new ArrayList<>();
54 * The Key Constructor creates a {@link DummyPfModel} object with the given concept key and
55 * creates an empty TOSCA model.
57 * @param key the TOSCA model key
59 public DummyPfModel(final PfConceptKey key) {
61 this.keyList = new ArrayList<>();
65 * Constructor that initiates a {@link ToscaModel} with all its fields.
67 * @param key the TOSCA model key
68 * @param keyList the service templates in the event model
70 public DummyPfModel(final PfConceptKey key, final List<PfKey> keyList) {
72 this.keyList = keyList;
78 * @param copyConcept the concept to copy from
80 public DummyPfModel(final DummyPfModel copyConcept) {
83 this.keyList = new ArrayList<>();
84 for (final PfKey pfKey : copyConcept.keyList) {
85 keyList.add(PfUtils.makeCopy(pfKey));
90 public void register() {
95 public List<PfKey> getKeys() {
96 final List<PfKey> listOfKeys = super.getKeys();
98 listOfKeys.addAll(keyList);
104 public void clean() {
106 for (PfKey pfKey : keyList) {
112 public BeanValidationResult validate(@NonNull String fieldName) {
113 BeanValidationResult result = super.validate(fieldName);
116 for (PfKey pfKey : keyList) {
117 result.addResult(pfKey.validate("keyList." + (count++)));
124 public int compareTo(final PfConcept otherConcept) {
125 if (super.compareTo(otherConcept) != 0) {
126 return super.compareTo(otherConcept);
129 if (otherConcept == null) {
133 if (this == otherConcept) {
137 if (getClass() != otherConcept.getClass()) {
138 return this.hashCode() - otherConcept.hashCode();
141 final DummyPfModel other = (DummyPfModel) otherConcept;
142 if (!super.equals(other)) {
143 return super.compareTo(other);
146 if (!keyList.equals(other.keyList)) {
147 return (keyList.hashCode() - other.keyList.hashCode());