當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanWrapper.setAutoGrowNestedPaths方法代碼示例

本文整理匯總了Java中org.springframework.beans.BeanWrapper.setAutoGrowNestedPaths方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanWrapper.setAutoGrowNestedPaths方法的具體用法?Java BeanWrapper.setAutoGrowNestedPaths怎麽用?Java BeanWrapper.setAutoGrowNestedPaths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.BeanWrapper的用法示例。


在下文中一共展示了BeanWrapper.setAutoGrowNestedPaths方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: applyMapOntoInstance

import org.springframework.beans.BeanWrapper; //導入方法依賴的package包/類
/**
 * Injects the properties from the given Map to the given object. Additionally, a bean factory can be passed in for
 * copying property editors inside the injector.
 * 
 * @param instance bean instance to configure
 * @param properties
 * @param beanFactory
 */
public static void applyMapOntoInstance(Object instance, Map<String, ?> properties, AbstractBeanFactory beanFactory) {
	if (properties != null && !properties.isEmpty()) {
		BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(instance);
		beanWrapper.setAutoGrowNestedPaths(true);

		// configure bean wrapper (using method from Spring 2.5.6)
		if (beanFactory != null) {
			beanFactory.copyRegisteredEditorsTo(beanWrapper);
		}
		for (Iterator<?> iterator = properties.entrySet().iterator(); iterator.hasNext();) {
			Map.Entry<String, ?> entry = (Map.Entry<String, ?>) iterator.next();
			String propertyName = entry.getKey();
			if (beanWrapper.isWritableProperty(propertyName)) {
				beanWrapper.setPropertyValue(propertyName, entry.getValue());
			}
		}
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:27,代碼來源:CMUtils.java

示例2: modifyProperties

import org.springframework.beans.BeanWrapper; //導入方法依賴的package包/類
/**
 * Modify the property values so that period separated property paths are valid for
 * map keys. Also creates new maps for properties of map type that are null (assuming
 * all maps are potentially nested). The standard bracket {@code[...]} dereferencing
 * is also accepted.
 * @param propertyValues the property values
 * @param target the target object
 * @return modified property values
 */
private MutablePropertyValues modifyProperties(MutablePropertyValues propertyValues,
		Object target) {
	propertyValues = getPropertyValuesForNamePrefix(propertyValues);
	if (target instanceof MapHolder) {
		propertyValues = addMapPrefix(propertyValues);
	}
	BeanWrapper wrapper = new BeanWrapperImpl(target);
	wrapper.setConversionService(
			new RelaxedConversionService(getConversionService()));
	wrapper.setAutoGrowNestedPaths(true);
	List<PropertyValue> sortedValues = new ArrayList<PropertyValue>();
	Set<String> modifiedNames = new HashSet<String>();
	List<String> sortedNames = getSortedPropertyNames(propertyValues);
	for (String name : sortedNames) {
		PropertyValue propertyValue = propertyValues.getPropertyValue(name);
		PropertyValue modifiedProperty = modifyProperty(wrapper, propertyValue);
		if (modifiedNames.add(modifiedProperty.getName())) {
			sortedValues.add(modifiedProperty);
		}
	}
	return new MutablePropertyValues(sortedValues);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:32,代碼來源:RelaxedDataBinder.java


注:本文中的org.springframework.beans.BeanWrapper.setAutoGrowNestedPaths方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。