当前位置: 首页>>代码示例>>Java>>正文


Java BeanWrapperImpl.setPropertyValue方法代码示例

本文整理汇总了Java中org.springframework.beans.BeanWrapperImpl.setPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:Java BeanWrapperImpl.setPropertyValue方法的具体用法?Java BeanWrapperImpl.setPropertyValue怎么用?Java BeanWrapperImpl.setPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.BeanWrapperImpl的用法示例。


在下文中一共展示了BeanWrapperImpl.setPropertyValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBeanWrapperCreatesNewNestedMaps

import org.springframework.beans.BeanWrapperImpl; //导入方法依赖的package包/类
@Test
public void testBeanWrapperCreatesNewNestedMaps() throws Exception {
	TargetWithNestedMap target = new TargetWithNestedMap();
	BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
	wrapper.setAutoGrowNestedPaths(true);
	// For a nested map, you only have to get an element of it for it to be created
	wrapper.getPropertyValue("nested[foo]");
	// To decide what type to create for nested[foo] we need to look ahead and see
	// what the user is trying to bind it to, e.g. if nested[foo][bar] then it's a map
	wrapper.setPropertyValue("nested[foo]", new LinkedHashMap<String, Object>());
	// But it might equally well be a collection, if nested[foo][0]
	wrapper.setPropertyValue("nested[foo]", new ArrayList<Object>());
	// Then it would have to be actually bound to get the list to auto-grow
	wrapper.setPropertyValue("nested[foo][0]", "bar");
	assertThat(wrapper.getPropertyValue("nested[foo][0]")).isNotNull();
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:17,代码来源:BindingPreparationTests.java

示例2: testBeanWrapperCreatesNewMapEntries

import org.springframework.beans.BeanWrapperImpl; //导入方法依赖的package包/类
@Test
public void testBeanWrapperCreatesNewMapEntries() throws Exception {
	TargetWithNestedMapOfBean target = new TargetWithNestedMapOfBean();
	BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
	wrapper.setAutoGrowNestedPaths(true);
	// For a nested map, you only have to get an element of it for it to be created
	wrapper.getPropertyValue("nested[foo]");
	wrapper.setPropertyValue("nested[foo].foo", "bar");
	assertThat(wrapper.getPropertyValue("nested")).isNotNull();
	assertThat(wrapper.getPropertyValue("nested[foo]")).isNotNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:BindingPreparationTests.java

示例3: testBeanWrapperCreatesNewObjects

import org.springframework.beans.BeanWrapperImpl; //导入方法依赖的package包/类
@Test
public void testBeanWrapperCreatesNewObjects() throws Exception {
	TargetWithNestedObject target = new TargetWithNestedObject();
	BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
	wrapper.setAutoGrowNestedPaths(true);
	// For a nested object, you have to set a property for it to be created
	wrapper.setPropertyValue("nested.foo", "bar");
	wrapper.getPropertyValue("nested");
	assertThat(wrapper.getPropertyValue("nested")).isNotNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:BindingPreparationTests.java

示例4: testBeanWrapperLists

import org.springframework.beans.BeanWrapperImpl; //导入方法依赖的package包/类
@Test
public void testBeanWrapperLists() throws Exception {
	TargetWithNestedMapOfListOfString target = new TargetWithNestedMapOfListOfString();
	BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
	wrapper.setAutoGrowNestedPaths(true);
	TypeDescriptor descriptor = wrapper.getPropertyTypeDescriptor("nested");
	assertThat(descriptor.isMap()).isTrue();
	wrapper.getPropertyValue("nested[foo]");
	assertThat(wrapper.getPropertyValue("nested")).isNotNull();
	// You also need to bind to a value here
	wrapper.setPropertyValue("nested[foo][0]", "bar");
	wrapper.getPropertyValue("nested[foo][0]");
	assertThat(wrapper.getPropertyValue("nested[foo]")).isNotNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:BindingPreparationTests.java


注:本文中的org.springframework.beans.BeanWrapperImpl.setPropertyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。