Changes for Checkstyle 8.32
[policy/models.git] / models-base / src / main / java / org / onap / policy / models / base / PfConcept.java
1 /*-
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.models.base;
23
24 import java.io.Serializable;
25 import java.util.List;
26 import lombok.NonNull;
27
28 /**
29  * This class is the base class for all Policy Framework concept classes. It enforces implementation of abstract methods
30  * and interfaces on all concepts that are sub-classes of this class.
31  */
32
33 public abstract class PfConcept implements Serializable, Comparable<PfConcept> {
34     private static final long serialVersionUID = -7434939557282697490L;
35
36     /**
37      * Default constructor.
38      */
39     public PfConcept() {
40         // Default Constructor
41     }
42
43     /**
44      * Copy constructor.
45      *
46      * @param copyConcept the concept to copy from
47      */
48     public PfConcept(@NonNull final PfConcept copyConcept) {
49         // nothing else to do (other than @NonNull check)
50     }
51
52     /**
53      * Gets the key of this concept.
54      *
55      * @return the concept key
56      */
57     public abstract PfKey getKey();
58
59     /**
60      * Gets a list of all keys for this concept and all concepts that are defined or referenced by this concept and its
61      * sub-concepts.
62      *
63      * @return the keys used by this concept and its contained concepts
64      */
65     public abstract List<PfKey> getKeys();
66
67     /**
68      * Validate that this concept is structurally correct.
69      *
70      * @param result the parameter in which the result of the validation will be returned
71      * @return the validation result that was passed in in the @{link result} field with the result of this validation
72      *         added
73      */
74     public abstract PfValidationResult validate(@NonNull final PfValidationResult result);
75
76     /**
77      * Clean this concept, tidy up any superfluous information such as leading and trailing white space.
78      */
79     public abstract void clean();
80
81     @Override
82     public abstract boolean equals(Object otherObject);
83
84     @Override
85     public abstract String toString();
86
87     @Override
88     public abstract int hashCode();
89
90     /**
91      * Gets the ID string of this concept.
92      *
93      * @return the ID string of this concept
94      */
95     public String getId() {
96         return getKey().getId();
97     }
98
99     /**
100      * Gets the name of this concept.
101      *
102      * @return the name of this concept
103      */
104     public String getName() {
105         return getKey().getName();
106     }
107
108     /**
109      * Gets the version of this concept.
110      *
111      * @return the version of this concept
112      */
113     public String getVersion() {
114         return getKey().getVersion();
115     }
116
117     /**
118      * Checks if this key matches the given key ID.
119      *
120      * @param id the key ID to match against
121      * @return true, if this key matches the ID
122      */
123     public final boolean matchesId(@NonNull final String id) {
124         // Check the ID
125         return getId().equals(id);
126     }
127 }