Changes for checkstyle 8.32
[policy/apex-pdp.git] / model / basic-model / src / main / java / org / onap / policy / apex / model / basicmodel / concepts / AxConcept.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2019 Nordix Foundation.
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.apex.model.basicmodel.concepts;
23
24 import java.io.Serializable;
25 import java.util.List;
26 import javax.xml.bind.annotation.XmlType;
27 import org.onap.policy.common.utils.validation.Assertions;
28
29 /**
30  * This class is the base class for all Apex concept classes. It enforces implementation of abstract methods and
31  * interfaces on all concepts that are sub-classes of this class.
32  *
33  * @author Liam Fallon (liam.fallon@ericsson.com)
34  */
35
36 @XmlType(name = "AxConcept", namespace = "http://www.onap.org/policy/apex-pdp")
37
38 public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
39     private static final long serialVersionUID = -7434939557282697490L;
40
41     /**
42      * Default constructor.
43      */
44     public AxConcept() {
45         // Default constructor
46     }
47
48     /**
49      * Copy constructor.
50      *
51      * @param copyConcept the concept to copy from
52      */
53     public AxConcept(final AxConcept copyConcept) {
54         Assertions.argumentNotNull(copyConcept, "copy concept may not be null");
55         copyConcept.copyTo(this);
56     }
57
58     /**
59      * Gets the key of this concept.
60      *
61      * @return the concept key
62      */
63     public abstract AxKey getKey();
64
65     /**
66      * Gets a list of all keys for this concept and all concepts that are defined or referenced by this concept and its
67      * sub-concepts.
68      *
69      * @return the keys used by this concept and it's contained concepts
70      */
71     public abstract List<AxKey> getKeys();
72
73     /**
74      * Validate that this concept is structurally correct.
75      *
76      * @param result the parameter in which the result of the validation will be returned
77      * @return the validation result that was passed in in the @{link result} field with the result of this validation
78      *         added
79      */
80     public abstract AxValidationResult validate(AxValidationResult result);
81
82     /**
83      * Clean this concept, tidy up any superfluous information such as leading and trailing white space.
84      */
85     public abstract void clean();
86
87     /**
88      * {@inheritDoc}.
89      */
90     @Override
91     public abstract boolean equals(Object otherObject);
92
93     /**
94      * {@inheritDoc}.
95      */
96     @Override
97     public abstract String toString();
98
99     /**
100      * {@inheritDoc}.
101      */
102     @Override
103     public abstract int hashCode();
104
105     /**
106      * Copy this concept to another object. The target object must have the same class as the source object.
107      *
108      * @param target the target object to which this object is copied
109      * @return the copied object
110      */
111     public abstract AxConcept copyTo(AxConcept target);
112
113     /**
114      * Gets the ID string of this concept.
115      *
116      * @return the ID string of this concept
117      */
118     public String getId() {
119         return getKey().getId();
120     }
121
122     /**
123      * Checks if this key matches the given key ID.
124      *
125      * @param id the key ID to match against
126      * @return true, if this key matches the ID
127      */
128     public final boolean matchesId(final String id) {
129         Assertions.argumentNotNull(id, "id may not be null");
130
131         // Check the ID
132         return getId().equals(id);
133     }
134 }