001/* 002 * Copyright © 2025 CUI-OpenSource-Software (info@cuioss.de) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.cuioss.test.generator.internal.net.java.quickcheck; 017 018import lombok.Getter; 019 020import java.io.Serial; 021 022/** 023 * Indicates that a characteristic specification was not true for a given 024 * instance. 025 */ 026@SuppressWarnings("java:S1948") // owolff: not a problem for test-code 027public class CharacteristicException extends RuntimeException { 028 029 @Serial 030 private static final long serialVersionUID = 1L; 031 032 private final Object instance; 033 034 @Getter 035 private final Characteristic<?> charateristic; 036 037 /** 038 * @param message error message 039 * @param cause causing exception thrown by characteristic 040 * @param charateristic characteristic violated 041 */ 042 public CharacteristicException(String message, Throwable cause, Characteristic<?> charateristic) { 043 this(message, cause, charateristic, null); 044 } 045 046 /** 047 * @param message error message 048 * @param cause causing exception thrown by characteristic 049 * @param instance violating the specified characteristic 050 * @param charateristic characteristic violated 051 */ 052 public CharacteristicException(String message, Throwable cause, Characteristic<?> charateristic, Object instance) { 053 super(message, cause); 054 this.instance = instance; 055 this.charateristic = charateristic; 056 } 057 058 /** 059 * Instance causing the characteristic violation. 060 * 061 * @return the violating instance 062 */ 063 public Object getInstance() { 064 return instance; 065 } 066}