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
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.apex.model.basicmodel.concepts;
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;
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.
33 * @author Liam Fallon (liam.fallon@ericsson.com)
36 @XmlType(name = "AxConcept", namespace = "http://www.onap.org/policy/apex-pdp")
38 public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
39 private static final long serialVersionUID = -7434939557282697490L;
42 * Default constructor.
45 // Default constructor
51 * @param copyConcept the concept to copy from
53 public AxConcept(final AxConcept copyConcept) {
54 Assertions.argumentNotNull(copyConcept, "copy concept may not be null");
55 copyConcept.copyTo(this);
59 * Gets the key of this concept.
61 * @return the concept key
63 public abstract AxKey getKey();
66 * Gets a list of all keys for this concept and all concepts that are defined or referenced by this concept and its
69 * @return the keys used by this concept and it's contained concepts
71 public abstract List<AxKey> getKeys();
74 * Validate that this concept is structurally correct.
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
80 public abstract AxValidationResult validate(AxValidationResult result);
83 * Clean this concept, tidy up any superfluous information such as leading and trailing white space.
85 public abstract void clean();
91 public abstract boolean equals(Object otherObject);
97 public abstract String toString();
103 public abstract int hashCode();
106 * Copy this concept to another object. The target object must have the same class as the source object.
108 * @param target the target object to which this object is copied
109 * @return the copied object
111 public abstract AxConcept copyTo(AxConcept target);
114 * Gets the ID string of this concept.
116 * @return the ID string of this concept
118 public String getId() {
119 return getKey().getId();
123 * Checks if this key matches the given key ID.
125 * @param id the key ID to match against
126 * @return true, if this key matches the ID
128 public final boolean matchesId(final String id) {
129 Assertions.argumentNotNull(id, "id may not be null");
132 return getId().equals(id);