2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Modifications Copyright (C) 2019 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;
24 import java.io.Serializable;
25 import java.util.List;
27 import lombok.NonNull;
30 * This class is the base class for all Policy Framework concept classes. It enforces implementation of abstract methods
31 * and interfaces on all concepts that are sub-classes of this class.
34 public abstract class PfConcept implements Serializable, Comparable<PfConcept> {
35 private static final long serialVersionUID = -7434939557282697490L;
38 * Default constructor.
41 // Default Constructor
47 * @param copyConcept the concept to copy from
49 public PfConcept(@NonNull final PfConcept copyConcept) {
50 // nothing else to do (other than @NonNull check)
54 * Gets the key of this concept.
56 * @return the concept key
58 public abstract PfKey getKey();
61 * Gets a list of all keys for this concept and all concepts that are defined or referenced by this concept and its
64 * @return the keys used by this concept and its contained concepts
66 public abstract List<PfKey> getKeys();
69 * Validate that this concept is structurally correct.
71 * @param result the parameter in which the result of the validation will be returned
72 * @return the validation result that was passed in in the @{link result} field with the result of this validation
75 public abstract PfValidationResult validate(@NonNull final PfValidationResult result);
78 * Clean this concept, tidy up any superfluous information such as leading and trailing white space.
80 public abstract void clean();
83 public abstract boolean equals(Object otherObject);
86 public abstract String toString();
89 public abstract int hashCode();
92 * Gets the ID string of this concept.
94 * @return the ID string of this concept
96 public String getId() {
97 return getKey().getId();
101 * Gets the name of this concept.
103 * @return the name of this concept
105 public String getName() {
106 return getKey().getName();
110 * Gets the version of this concept.
112 * @return the version of this concept
114 public String getVersion() {
115 return getKey().getVersion();
119 * Checks if this key matches the given key ID.
121 * @param id the key ID to match against
122 * @return true, if this key matches the ID
124 public final boolean matchesId(@NonNull final String id) {
126 return getId().equals(id);