001/* 002 * Copyright 2002-2012 the original author or authors. 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 * https://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 */ 016 017package org.springframework.beans; 018 019/** 020 * Exception thrown when referring to an invalid bean property. 021 * Carries the offending bean class and property name. 022 * 023 * @author Juergen Hoeller 024 * @since 1.0.2 025 */ 026@SuppressWarnings("serial") 027public class InvalidPropertyException extends FatalBeanException { 028 029 private Class<?> beanClass; 030 031 private String propertyName; 032 033 034 /** 035 * Create a new InvalidPropertyException. 036 * @param beanClass the offending bean class 037 * @param propertyName the offending property 038 * @param msg the detail message 039 */ 040 public InvalidPropertyException(Class<?> beanClass, String propertyName, String msg) { 041 this(beanClass, propertyName, msg, null); 042 } 043 044 /** 045 * Create a new InvalidPropertyException. 046 * @param beanClass the offending bean class 047 * @param propertyName the offending property 048 * @param msg the detail message 049 * @param cause the root cause 050 */ 051 public InvalidPropertyException(Class<?> beanClass, String propertyName, String msg, Throwable cause) { 052 super("Invalid property '" + propertyName + "' of bean class [" + beanClass.getName() + "]: " + msg, cause); 053 this.beanClass = beanClass; 054 this.propertyName = propertyName; 055 } 056 057 /** 058 * Return the offending bean class. 059 */ 060 public Class<?> getBeanClass() { 061 return beanClass; 062 } 063 064 /** 065 * Return the name of the offending property. 066 */ 067 public String getPropertyName() { 068 return propertyName; 069 } 070 071}