下面列出了怎么用org.springframework.beans.NotReadablePropertyException的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
@Nullable
public Object getValue(String paramName) throws IllegalArgumentException {
try {
return this.beanWrapper.getPropertyValue(paramName);
}
catch (NotReadablePropertyException ex) {
throw new IllegalArgumentException(ex.getMessage());
}
}
@Override
@Nullable
public Object getValue(String paramName) throws IllegalArgumentException {
try {
return this.beanWrapper.getPropertyValue(paramName);
}
catch (NotReadablePropertyException ex) {
throw new IllegalArgumentException(ex.getMessage());
}
}
@Override
public Object getValue(String paramName) throws IllegalArgumentException {
try {
return this.beanWrapper.getPropertyValue(paramName);
}
catch (NotReadablePropertyException ex) {
throw new IllegalArgumentException(ex.getMessage());
}
}
@Override
public Object getValue(String paramName) throws IllegalArgumentException {
try {
return this.beanWrapper.getPropertyValue(paramName);
}
catch (NotReadablePropertyException ex) {
throw new IllegalArgumentException(ex.getMessage());
}
}
@Override
public Object getValue(String paramName) throws IllegalArgumentException {
try {
return this.beanWrapper.getPropertyValue(paramName);
}
catch (NotReadablePropertyException ex) {
throw new IllegalArgumentException(ex.getMessage());
}
}
/**
* Checks whether the given property is secure.
*
* @param wrappedClass class the property is associated with
* @param propertyPath path to the property
* @return boolean true if the property is secure, false if not
*/
protected boolean isSecure(Class<?> wrappedClass, String propertyPath) {
if (KRADUtils.isSecure(propertyPath, wrappedClass)) {
return true;
}
// since this is part of a set, we want to make sure nested paths grow
setAutoGrowNestedPaths(true);
BeanWrapperImpl beanWrapper;
try {
beanWrapper = getBeanWrapperForPropertyPath(propertyPath);
} catch (NotReadablePropertyException | NullValueInNestedPathException e) {
LOG.debug("Bean wrapper was not found for " + propertyPath
+ ", but since it cannot be accessed it will not be set as secure.", e);
return false;
}
if (org.apache.commons.lang.StringUtils.isNotBlank(beanWrapper.getNestedPath())) {
PropertyTokenHolder tokens = getPropertyNameTokens(propertyPath);
String nestedPropertyPath = org.apache.commons.lang.StringUtils.removeStart(tokens.canonicalName,
beanWrapper.getNestedPath());
return isSecure(beanWrapper.getWrappedClass(), nestedPropertyPath);
}
return false;
}
@Override
public Object getPropertyValue(String propertyName) throws BeansException {
Field field = this.fieldMap.get(propertyName);
if (field == null) {
throw new NotReadablePropertyException(
this.target.getClass(), propertyName, "Field '" + propertyName + "' does not exist");
}
try {
ReflectionUtils.makeAccessible(field);
return field.get(this.target);
}
catch (IllegalAccessException ex) {
throw new InvalidPropertyException(this.target.getClass(), propertyName, "Field is not accessible", ex);
}
}