2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
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.models.base;
24 import org.onap.policy.common.utils.validation.Assertions;
25 import org.onap.policy.models.base.PfValidationResult.ValidationResult;
28 * A validation message is created for each validation observation observed during validation of a
29 * concept. The message holds the key and the class of the concept on which the observation was made
30 * as well as the type of observation and a message describing the observation.
32 public class PfValidationMessage {
33 private final PfKey observedKey;
34 private ValidationResult validationResult = ValidationResult.VALID;
35 private final String observedClass;
36 private final String message;
39 * Create an validation observation with the given fields.
41 * @param observedKey the key of the class on which the validation observation was made
42 * @param observedClass the class on which the validation observation was made
43 * @param validationResult the type of observation made
44 * @param message a message describing the observation
46 public PfValidationMessage(final PfKey observedKey, final Class<?> observedClass,
47 final ValidationResult validationResult, final String message) {
48 Assertions.argumentNotNull(observedKey, "observedKey may not be null");
49 Assertions.argumentNotNull(observedClass, "observedClass may not be null");
50 Assertions.argumentNotNull(validationResult, "validationResult may not be null");
51 Assertions.argumentNotNull(message, "message may not be null");
53 this.observedKey = observedKey;
54 this.observedClass = observedClass.getName();
55 this.validationResult = validationResult;
56 this.message = message;
60 * Gets the key of the observation.
62 * @return the key of the observation
64 public PfKey getObservedKey() {
69 * Gets the observed class.
71 * @return the observed class
73 public String getObservedClass() {
78 * Gets the type of observation made.
80 * @return the type of observation made
82 public ValidationResult getValidationResult() {
83 return validationResult;
87 * Get a description of the observation.
89 * @return the observation description
91 public String getMessage() {
98 * @see java.lang.Object#toString()
101 public String toString() {
102 return observedKey.toString() + ':' + observedClass + ':' + validationResult.name() + ':' + message;