本文整理汇总了Java中org.springframework.beans.BeanWrapper.getPropertyType方法的典型用法代码示例。如果您正苦于以下问题:Java BeanWrapper.getPropertyType方法的具体用法?Java BeanWrapper.getPropertyType怎么用?Java BeanWrapper.getPropertyType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.BeanWrapper
的用法示例。
在下文中一共展示了BeanWrapper.getPropertyType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveNestedPropertyName
import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
private String resolveNestedPropertyName(BeanWrapper target, String prefix,
String name) {
StringBuilder candidate = new StringBuilder();
for (String field : name.split("[_\\-\\.]")) {
candidate.append(candidate.length() > 0 ? "." : "");
candidate.append(field);
String nested = resolvePropertyName(target, prefix, candidate.toString());
if (nested != null) {
Class<?> type = target.getPropertyType(nested);
if ((type != null) && Map.class.isAssignableFrom(type)) {
// Special case for map property (gh-3836).
return nested + "[" + name.substring(candidate.length() + 1) + "]";
}
String propertyName = resolvePropertyName(target,
joinString(prefix, nested),
name.substring(candidate.length() + 1));
if (propertyName != null) {
return joinString(nested, propertyName);
}
}
}
return null;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:24,代码来源:RelaxedDataBinder.java
示例2: resolvePropertyName
import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
private String resolvePropertyName(BeanWrapper target, String prefix, String name) {
Iterable<String> names = getNameAndAliases(name);
for (String nameOrAlias : names) {
for (String candidate : new RelaxedNames(nameOrAlias)) {
try {
if (target.getPropertyType(joinString(prefix, candidate)) != null) {
return candidate;
}
}
catch (InvalidPropertyException ex) {
// swallow and continue
}
}
}
return null;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:RelaxedDataBinder.java
示例3: testUseBlueprintExceptions
import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
public void testUseBlueprintExceptions() throws Exception {
OsgiServiceProxyFactoryBean fb = new OsgiServiceProxyFactoryBean();
BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(fb);
String propertyName = "useBlueprintExceptions";
for (PropertyDescriptor desc : wrapper.getPropertyDescriptors()) {
System.out.println(desc.getName());
}
Class type = wrapper.getPropertyType(propertyName);
System.out.println("type is " + type);
assertTrue(wrapper.isWritableProperty(propertyName));
assertFalse(wrapper.isReadableProperty(propertyName));
}
示例4: getTypeDescriptor
import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
/**
* Obtains the descriptor of the filtered field
*
* @param fieldName
* @param entityType
* @return
*/
public static <T> TypeDescriptor getTypeDescriptor(String fieldName,
Class<T> entityType) {
String fieldNameToFindType = fieldName;
BeanWrapper beanWrapper = getBeanWrapper(entityType);
TypeDescriptor fieldDescriptor = null;
Class<?> propType = null;
// Find recursive the las beanWrapper
if (fieldName.contains(SEPARATOR_FIELDS)) {
String[] fieldNameSplitted = StringUtils.split(fieldName,
SEPARATOR_FIELDS);
for (int i = 0; i < fieldNameSplitted.length - 1; i++) {
propType = beanWrapper.getPropertyType(fieldNameSplitted[i]);
if (propType == null) {
throw new IllegalArgumentException(String.format(
"Property %s not found in %s (request %s.%s)",
fieldNameSplitted[i],
beanWrapper.getWrappedClass(), entityType,
fieldName));
}
beanWrapper = getBeanWrapper(propType);
}
fieldNameToFindType = fieldNameSplitted[fieldNameSplitted.length - 1];
}
fieldDescriptor = beanWrapper
.getPropertyTypeDescriptor(fieldNameToFindType);
return fieldDescriptor;
}
示例5: getTypeDescriptor
import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <T> TypeDescriptor getTypeDescriptor(String fieldName,
Class<T> entityType) {
String fieldNameToFindType = fieldName;
BeanWrapper beanWrapper = getBeanWrapper(entityType);
TypeDescriptor fieldDescriptor = null;
Class<?> propType = null;
// Find recursive the las beanWrapper
if (fieldName.contains(SEPARATOR_FIELDS)) {
String[] fieldNameSplitted = StringUtils.split(fieldName,
SEPARATOR_FIELDS);
for (int i = 0; i < fieldNameSplitted.length - 1; i++) {
propType = beanWrapper.getPropertyType(fieldNameSplitted[i]);
if (propType == null) {
throw new IllegalArgumentException(String.format(
"Property %s not found in %s (request %s.%s)",
fieldNameSplitted[i],
beanWrapper.getWrappedClass(), entityType,
fieldName));
}
beanWrapper = getBeanWrapper(propType);
}
fieldNameToFindType = fieldNameSplitted[fieldNameSplitted.length - 1];
}
fieldDescriptor = beanWrapper
.getPropertyTypeDescriptor(fieldNameToFindType);
return fieldDescriptor;
}