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.models.base;
23 import java.io.Serializable;
24 import java.util.List;
26 import lombok.NonNull;
29 * This class is the base class for all Policy Framework concept classes. It enforces implementation
30 * of abstract methods and interfaces on all concepts that are sub-classes of this class.
33 public abstract class PfConcept implements Serializable, Comparable<PfConcept> {
34 private static final long serialVersionUID = -7434939557282697490L;
37 * Default constructor.
44 * @param copyConcept the concept to copy from
46 public PfConcept(@NonNull final PfConcept copyConcept) {
47 copyConcept.copyTo(this);
51 * Gets the key of this concept.
53 * @return the concept key
55 public abstract PfKey getKey();
58 * Gets a list of all keys for this concept and all concepts that are defined or referenced by
59 * this concept and its sub-concepts.
61 * @return the keys used by this concept and its contained concepts
63 public abstract List<PfKey> getKeys();
66 * Validate that this concept is structurally correct.
68 * @param result the parameter in which the result of the validation will be returned
69 * @return the validation result that was passed in in the @{link result} field with the result
70 * of this validation added
72 public abstract PfValidationResult validate(@NonNull final PfValidationResult result);
75 * Clean this concept, tidy up any superfluous information such as leading and trailing white
78 public abstract void clean();
81 public abstract boolean equals(Object otherObject);
84 public abstract String toString();
87 public abstract int hashCode();
90 * Copy this concept to another object. The target object must have the same class as the source
93 * @param target the target object to which this object is copied
94 * @return the copied object
96 public abstract PfConcept copyTo(@NonNull PfConcept target);
99 * Gets the ID string of this concept.
101 * @return the ID string of this concept
103 public String getId() {
104 return getKey().getId();
108 * Gets the name of this concept.
110 * @return the name of this concept
112 public String getName() {
113 return getKey().getName();
117 * Gets the version of this concept.
119 * @return the version of this concept
121 public String getVersion() {
122 return getKey().getVersion();
126 * Checks if this key matches the given key ID.
128 * @param id the key ID to match against
129 * @return true, if this key matches the ID
131 public final boolean matchesId(@NonNull final String id) {
133 return getId().equals(id);