org.springframework.beans.MutablePropertyValues#getPropertyValueList ( )源码实例Demo

下面列出了org.springframework.beans.MutablePropertyValues#getPropertyValueList ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

protected void addBindValues(MutablePropertyValues mpvs, ServletRequest request) {
    super.addBindValues(mpvs, request);

    //处理JsonProperty注释的对象
    Class<?> targetClass = getTarget().getClass();
    Field[] fields = targetClass.getDeclaredFields();
    for (Field field : fields) {
        JsonProperty jsonPropertyAnnotation = field.getAnnotation(JsonProperty.class);
        if (jsonPropertyAnnotation != null && mpvs.contains(jsonPropertyAnnotation.value())) {
            if (!mpvs.contains(field.getName())) {
                mpvs.add(field.getName(), mpvs.getPropertyValue(jsonPropertyAnnotation.value()).getValue());
            }
        }
    }

    List<PropertyValue> covertValues = new ArrayList<PropertyValue>();
    for (PropertyValue propertyValue : mpvs.getPropertyValueList()) {
        if(propertyValue.getName().contains("_")) {
            String camelName = SnakeToCamelRequestParameterUtil.convertSnakeToCamel(propertyValue.getName());
            if (!mpvs.contains(camelName)) {
                covertValues.add(new PropertyValue(camelName, propertyValue.getValue()));
            }
        }
    }
    mpvs.getPropertyValueList().addAll(covertValues);
}
 
源代码2 项目: alfresco-repository   文件: BeanExtender.java
/**
 * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
{
    ParameterCheck.mandatory("beanName", beanName);
    ParameterCheck.mandatory("extendingBeanName", extendingBeanName);

    // check for bean name
    if (!beanFactory.containsBean(beanName))
    {
        throw new NoSuchBeanDefinitionException("Can't find bean '" + beanName + "' to be extended.");
    }

    // check for extending bean
    if (!beanFactory.containsBean(extendingBeanName))
    {
        throw new NoSuchBeanDefinitionException("Can't find bean '" + extendingBeanName + "' that is going to extend original bean definition.");
    }

    // get the bean definitions
    BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
    BeanDefinition extendingBeanDefinition = beanFactory.getBeanDefinition(extendingBeanName);

    // update class
    if (StringUtils.isNotBlank(extendingBeanDefinition.getBeanClassName()) &&
        !beanDefinition.getBeanClassName().equals(extendingBeanDefinition.getBeanClassName()))
    {
        beanDefinition.setBeanClassName(extendingBeanDefinition.getBeanClassName());
    }

    // update properties
    MutablePropertyValues properties = beanDefinition.getPropertyValues();
    MutablePropertyValues extendingProperties = extendingBeanDefinition.getPropertyValues();
    for (PropertyValue propertyValue : extendingProperties.getPropertyValueList())
    {
        properties.add(propertyValue.getName(), propertyValue.getValue());
    }
}
 
/**
 * プロパティ名を取得します。
 * 
 * @param mpvs
 * @return
 */
private List<String> getPropertyNames(MutablePropertyValues mpvs) {
    val list = new ArrayList<String>();
    for (val pv : mpvs.getPropertyValueList()) {
        list.add(pv.getName());
    }
    return list;
}
 
源代码4 项目: apollo   文件: SpringValueDefinitionProcessor.java
private void processPropertyValues(BeanDefinitionRegistry beanRegistry) {
  if (!PROPERTY_VALUES_PROCESSED_BEAN_FACTORIES.add(beanRegistry)) {
    // already initialized
    return;
  }

  if (!beanName2SpringValueDefinitions.containsKey(beanRegistry)) {
    beanName2SpringValueDefinitions.put(beanRegistry, LinkedListMultimap.<String, SpringValueDefinition>create());
  }

  Multimap<String, SpringValueDefinition> springValueDefinitions = beanName2SpringValueDefinitions.get(beanRegistry);

  String[] beanNames = beanRegistry.getBeanDefinitionNames();
  for (String beanName : beanNames) {
    BeanDefinition beanDefinition = beanRegistry.getBeanDefinition(beanName);
    MutablePropertyValues mutablePropertyValues = beanDefinition.getPropertyValues();
    List<PropertyValue> propertyValues = mutablePropertyValues.getPropertyValueList();
    for (PropertyValue propertyValue : propertyValues) {
      Object value = propertyValue.getValue();
      if (!(value instanceof TypedStringValue)) {
        continue;
      }
      String placeholder = ((TypedStringValue) value).getValue();
      Set<String> keys = placeholderHelper.extractPlaceholderKeys(placeholder);

      if (keys.isEmpty()) {
        continue;
      }

      for (String key : keys) {
        springValueDefinitions.put(beanName, new SpringValueDefinition(key, placeholder, propertyValue.getName()));
      }
    }
  }
}
 
源代码5 项目: onetwo   文件: UnderlineBeanWrapper.java
protected MutablePropertyValues convertMutablePropertyValues(MutablePropertyValues mpvs){
	MutablePropertyValues newMpvs = new MutablePropertyValues();
	for(PropertyValue pv : mpvs.getPropertyValueList()){
		String propertyName = transformPropertyName(pv.getName());
		newMpvs.addPropertyValue(propertyName, pv.getValue());
	}
	return newMpvs;
}