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 org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
25 import org.onap.policy.common.utils.validation.Assertions;
28 * A validation message is created for each validation observation observed during validation of a concept. The message
29 * holds the key and the class of the concept on which the observation was made as well as the type of observation and a
30 * message describing the observation.
32 * @author Liam Fallon (liam.fallon@ericsson.com)
34 public class AxValidationMessage {
35 private final AxKey observedKey;
36 private ValidationResult validationResult = ValidationResult.VALID;
37 private final String observedClass;
38 private final String message;
41 * Create an validation observation with the given fields.
43 * @param observedKey the key of the class on which the validation observation was made
44 * @param observedClass the class on which the validation observation was made
45 * @param validationResult the type of observation made
46 * @param message a message describing the observation
48 public AxValidationMessage(final AxKey observedKey, final Class<?> observedClass,
49 final ValidationResult validationResult, final String message) {
50 Assertions.argumentNotNull(observedKey, "observedKey may not be null");
51 Assertions.argumentNotNull(observedClass, "observedClass may not be null");
52 Assertions.argumentNotNull(validationResult, "validationResult may not be null");
53 Assertions.argumentNotNull(message, "message may not be null");
55 this.observedKey = observedKey;
56 this.observedClass = observedClass.getCanonicalName();
57 this.validationResult = validationResult;
58 this.message = message;
62 * Gets the key of the observation.
64 * @return the key of the observation
66 public AxKey getObservedKey() {
71 * Gets the observed class.
73 * @return the observed class
75 public String getObservedClass() {
80 * Gets the type of observation made.
82 * @return the type of observation made
84 public ValidationResult getValidationResult() {
85 return validationResult;
89 * Get a description of the observation.
91 * @return the observation description
93 public String getMessage() {
100 * @see java.lang.Object#toString()
103 public String toString() {
104 return observedKey.toString() + ':' + observedClass + ':' + validationResult.name() + ':' + message;