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;
27 import javax.xml.bind.annotation.XmlType;
29 import org.onap.policy.common.utils.validation.Assertions;
32 * This class is the base class for all Apex concept classes. It enforces implementation of abstract methods and
33 * interfaces on all concepts that are sub-classes of this class.
35 * @author Liam Fallon (liam.fallon@ericsson.com)
38 @XmlType(name = "AxConcept", namespace = "http://www.onap.org/policy/apex-pdp")
40 public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
41 private static final long serialVersionUID = -7434939557282697490L;
44 * Default constructor.
47 // Default constructor
53 * @param copyConcept the concept to copy from
55 public AxConcept(final AxConcept copyConcept) {
56 Assertions.argumentNotNull(copyConcept, "copy concept may not be null");
57 copyConcept.copyTo(this);
61 * Gets the key of this concept.
63 * @return the concept key
65 public abstract AxKey getKey();
68 * Gets a list of all keys for this concept and all concepts that are defined or referenced by this concept and its
71 * @return the keys used by this concept and it's contained concepts
73 public abstract List<AxKey> getKeys();
76 * Validate that this concept is structurally correct.
78 * @param result the parameter in which the result of the validation will be returned
79 * @return the validation result that was passed in in the @{link result} field with the result of this validation
82 public abstract AxValidationResult validate(AxValidationResult result);
85 * Clean this concept, tidy up any superfluous information such as leading and trailing white space.
87 public abstract void clean();
93 public abstract boolean equals(Object otherObject);
99 public abstract String toString();
105 public abstract int hashCode();
108 * Copy this concept to another object. The target object must have the same class as the source object.
110 * @param target the target object to which this object is copied
111 * @return the copied object
113 public abstract AxConcept copyTo(AxConcept target);
116 * Gets the ID string of this concept.
118 * @return the ID string of this concept
120 public String getId() {
121 return getKey().getId();
125 * Checks if this key matches the given key ID.
127 * @param id the key ID to match against
128 * @return true, if this key matches the ID
130 public final boolean matchesId(final String id) {
131 Assertions.argumentNotNull(id, "id may not be null");
134 return getId().equals(id);