本文整理匯總了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;
}