2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.model.basicmodel.concepts;
23 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
24 import org.onap.policy.apex.model.utilities.Assertions;
27 * A validation message is created for each validation observation observed during validation of a concept. The message
28 * holds the key and the class of the concept on which the observation was made as well as the type of observation and a
29 * message describing the observation.
31 * @author Liam Fallon (liam.fallon@ericsson.com)
33 public class AxValidationMessage {
34 private final AxKey observedKey;
35 private ValidationResult validationResult = ValidationResult.VALID;
36 private final String observedClass;
37 private final String message;
40 * Create an validation observation with the given fields.
42 * @param observedKey the key of the class on which the validation observation was made
43 * @param observedClass the class on which the validation observation was made
44 * @param validationResult the type of observation made
45 * @param message a message describing the observation
47 public AxValidationMessage(final AxKey observedKey, final Class<?> observedClass,
48 final ValidationResult validationResult, final String message) {
49 Assertions.argumentNotNull(observedKey, "observedKey may not be null");
50 Assertions.argumentNotNull(observedClass, "observedClass may not be null");
51 Assertions.argumentNotNull(validationResult, "validationResult may not be null");
52 Assertions.argumentNotNull(message, "message may not be null");
54 this.observedKey = observedKey;
55 this.observedClass = observedClass.getCanonicalName();
56 this.validationResult = validationResult;
57 this.message = message;
61 * Gets the key of the observation.
63 * @return the key of the observation
65 public AxKey getObservedKey() {
70 * Gets the observed class.
72 * @return the observed class
74 public String getObservedClass() {
79 * Gets the type of observation made.
81 * @return the type of observation made
83 public ValidationResult getValidationResult() {
84 return validationResult;
88 * Get a description of the observation.
90 * @return the observation description
92 public String getMessage() {
99 * @see java.lang.Object#toString()
102 public String toString() {
103 return observedKey.toString() + ':' + observedClass + ':' + validationResult.name() + ':' + message;