本文整理了Java中org.springframework.beans.PropertyValue.setOptional()
方法的一些代码示例,展示了PropertyValue.setOptional()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PropertyValue.setOptional()
方法的具体详情如下:
包路径:org.springframework.beans.PropertyValue
类名称:PropertyValue
方法名:setOptional
[英]Set whether this is an optional value, that is, to be ignored when no corresponding property exists on the target class.
[中]
代码示例来源:origin: spring-projects/spring-framework
/**
* Apply the given property value to the corresponding bean.
*/
protected void applyPropertyValue(
ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
BeanDefinition bd = factory.getBeanDefinition(beanName);
BeanDefinition bdToUse = bd;
while (bd != null) {
bdToUse = bd;
bd = bd.getOriginatingBeanDefinition();
}
PropertyValue pv = new PropertyValue(property, value);
pv.setOptional(this.ignoreInvalidKeys);
bdToUse.getPropertyValues().addPropertyValue(pv);
}
代码示例来源:origin: org.springframework/spring-beans
/**
* Apply the given property value to the corresponding bean.
*/
protected void applyPropertyValue(
ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
BeanDefinition bd = factory.getBeanDefinition(beanName);
BeanDefinition bdToUse = bd;
while (bd != null) {
bdToUse = bd;
bd = bd.getOriginatingBeanDefinition();
}
PropertyValue pv = new PropertyValue(property, value);
pv.setOptional(this.ignoreInvalidKeys);
bdToUse.getPropertyValues().addPropertyValue(pv);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void setUnknownOptionalProperty() {
Simple target = new Simple("John", 2);
AbstractPropertyAccessor accessor = createAccessor(target);
try {
PropertyValue value = new PropertyValue("foo", "value");
value.setOptional(true);
accessor.setPropertyValue(value);
}
catch (NotWritablePropertyException e) {
fail("Should not have failed to set an unknown optional property.");
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Apply the given property value to the corresponding bean.
*/
protected void applyPropertyValue(
ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
BeanDefinition bd = factory.getBeanDefinition(beanName);
while (bd.getOriginatingBeanDefinition() != null) {
bd = bd.getOriginatingBeanDefinition();
}
PropertyValue pv = new PropertyValue(property, value);
pv.setOptional(this.ignoreInvalidKeys);
bd.getPropertyValues().addPropertyValue(pv);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Apply the given property value to the corresponding bean.
*/
protected void applyPropertyValue(
ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
BeanDefinition bd = factory.getBeanDefinition(beanName);
while (bd.getOriginatingBeanDefinition() != null) {
bd = bd.getOriginatingBeanDefinition();
}
PropertyValue pv = new PropertyValue(property, value);
pv.setOptional(this.ignoreInvalidKeys);
bd.getPropertyValues().addPropertyValue(pv);
}
代码示例来源:origin: stackoverflow.com
import java.beans.PropertyDescriptor;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
import org.springframework.stereotype.Component;
@Component
public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {
@Override
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
if (bean instanceof pak.Main) {
for (PropertyValue pv : pvs.getPropertyValues()) {
if ("human".equals(pv.getName())) {
pv.setOptional(true);
}
}
}
return pvs;
}
}
内容来源于网络,如有侵权,请联系作者删除!