Java Code Examples for org.springframework.beans.PropertyValue#getName()
The following examples show how to use
org.springframework.beans.PropertyValue#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrailsDataBinder.java From AlgoTrader with GNU General Public License v2.0 | 6 votes |
private ConstrainedProperty getConstrainedPropertyForPropertyValue(Map constrainedProperties, PropertyValue propertyValue) { final String propertyName = propertyValue.getName(); if (propertyName.indexOf(PATH_SEPARATOR) > -1) { String[] propertyNames = propertyName.split("\\."); Object target = getTarget(); Object value = getPropertyValueForPath(target, propertyNames); if (value != null) { Map nestedConstrainedProperties = resolveConstrainedProperties(value); if (nestedConstrainedProperties != null) { return (ConstrainedProperty) nestedConstrainedProperties.get(propertyNames[propertyNames.length - 1]); } } } else { return (ConstrainedProperty) constrainedProperties.get(propertyName); } return null; }
Example 2
Source File: GrailsDataBinder.java From AlgoTrader with GNU General Public License v2.0 | 6 votes |
private PropertyValues filterPropertyValues(PropertyValues propertyValues, String prefix) { if (prefix == null || prefix.length() == 0) return propertyValues; PropertyValue[] valueArray = propertyValues.getPropertyValues(); MutablePropertyValues newValues = new MutablePropertyValues(); for (PropertyValue propertyValue : valueArray) { String name = propertyValue.getName(); final String prefixWithDot = prefix + PREFIX_SEPERATOR; if (name.startsWith(prefixWithDot)) { name = name.substring(prefixWithDot.length(), name.length()); newValues.addPropertyValue(name, propertyValue.getValue()); } } return newValues; }
Example 3
Source File: BeanDefinitionDtoConverterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
/** * Convert from an internal Spring bean definition to a DTO. * * @param beanDefinition The internal Spring bean definition. * @return Returns a DTO representation. */ public BeanDefinitionInfo toDto(BeanDefinition beanDefinition) { if (beanDefinition instanceof GenericBeanDefinition) { GenericBeanDefinitionInfo info = new GenericBeanDefinitionInfo(); info.setClassName(beanDefinition.getBeanClassName()); if (beanDefinition.getPropertyValues() != null) { Map<String, BeanMetadataElementInfo> propertyValues = new HashMap<String, BeanMetadataElementInfo>(); for (PropertyValue value : beanDefinition.getPropertyValues().getPropertyValueList()) { Object obj = value.getValue(); if (obj instanceof BeanMetadataElement) { propertyValues.put(value.getName(), toDto((BeanMetadataElement) obj)); } else { throw new IllegalArgumentException("Type " + obj.getClass().getName() + " is not a BeanMetadataElement for property: " + value.getName()); } } info.setPropertyValues(propertyValues); } return info; } else { throw new IllegalArgumentException("Conversion to DTO of " + beanDefinition.getClass().getName() + " not implemented"); } }
Example 4
Source File: GrailsDataBinder.java From AlgoTrader with GNU General Public License v2.0 | 5 votes |
private String getNameOf(PropertyValue propertyValue) { String name = propertyValue.getName(); if (name.indexOf(STRUCTURED_PROPERTY_SEPERATOR) == -1) { return name; } return name.substring(0, name.indexOf(STRUCTURED_PROPERTY_SEPERATOR)); }
Example 5
Source File: ReloadingPropertyPlaceholderConfigurer.java From disconf with Apache License 2.0 | 5 votes |
protected void visitPropertyValues(MutablePropertyValues pvs) { PropertyValue[] pvArray = pvs.getPropertyValues(); for (PropertyValue pv : pvArray) { currentPropertyName = pv.getName(); try { Object newVal = resolveValue(pv.getValue()); if (!ObjectUtils.nullSafeEquals(newVal, pv.getValue())) { pvs.addPropertyValue(pv.getName(), newVal); } } finally { currentPropertyName = null; } } }
Example 6
Source File: ReloadingPropertyPlaceholderConfigurer.java From disconf with Apache License 2.0 | 5 votes |
protected void visitPropertyValues(MutablePropertyValues pvs) { PropertyValue[] pvArray = pvs.getPropertyValues(); for (PropertyValue pv : pvArray) { currentPropertyName = pv.getName(); try { Object newVal = resolveValue(pv.getValue()); if (!ObjectUtils.nullSafeEquals(newVal, pv.getValue())) { pvs.addPropertyValue(pv.getName(), newVal); } } finally { currentPropertyName = null; } } }
Example 7
Source File: OriginCapablePropertyValue.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
OriginCapablePropertyValue(PropertyValue propertyValue){ this(propertyValue.getName(), propertyValue.getValue(), (PropertyOrigin) propertyValue.getAttribute(ATTRIBUTE_PROPERTY_ORIGIN)); }
Example 8
Source File: GrailsDataBinder.java From AlgoTrader with GNU General Public License v2.0 | 4 votes |
private boolean isStructured(PropertyValue propertyValue) { String name = propertyValue.getName(); return name.indexOf(STRUCTURED_PROPERTY_SEPERATOR) != -1; }
Example 9
Source File: GrailsDataBinder.java From AlgoTrader with GNU General Public License v2.0 | 4 votes |
private boolean propertyStartsWithFieldMarkerPrefix(PropertyValue pv, String fieldMarkerPrefix) { String propertyName = pv.getName().indexOf(PATH_SEPARATOR) > -1 ? StringUtils.substringAfterLast(pv.getName(), ".") : pv.getName(); return propertyName.startsWith(fieldMarkerPrefix); }
Example 10
Source File: UifBeanFactoryPostProcessor.java From rice with Educational Community License v2.0 | 4 votes |
/** * If the bean class is type UifDictionaryBean, iterate through configured property values * and check for expressions. * * @param beanName name of the bean in the factory (only set for top level beans, not nested) * @param beanDefinition bean definition to process for expressions * @param nestedPropertyName * @param expressionGraph * @param beanFactory bean factory being processed * @param processedBeanNames */ protected void processNestedBeanDefinition(String beanName, BeanDefinition beanDefinition, String nestedPropertyName, Map<String, String> expressionGraph, ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) { Class<?> beanClass = getBeanClass(beanDefinition, beanFactory); if ((beanClass == null) || !UifDictionaryBean.class.isAssignableFrom(beanClass) || processedBeanNames.contains( beanName)) { return; } LOG.debug("Processing bean name '" + beanName + "'"); Map<String, String> parentExpressionGraph = getExpressionGraphFromParent(beanDefinition.getParentName(), beanFactory, processedBeanNames); // process expressions on property values MutablePropertyValues pvs = beanDefinition.getPropertyValues(); PropertyValue[] pvArray = pvs.getPropertyValues(); for (PropertyValue pv : pvArray) { if (pv.getName().equals(UifPropertyPaths.EXPRESSION_GRAPH)) { continue; } String propertyPath = pv.getName(); if (StringUtils.isNotBlank(nestedPropertyName)) { propertyPath = nestedPropertyName + "." + propertyPath; } // for reloading, need to remove the property from the previously loaded bean definition if (expressionGraph.containsKey(propertyPath)) { expressionGraph.remove(propertyPath); } if (hasExpression(pv.getValue())) { // process expression String strValue = getStringValue(pv.getValue()); expressionGraph.put(propertyPath, strValue); // remove property value so expression will not cause binding exception pvs.removePropertyValue(pv.getName()); } else { // process nested objects Object newValue = processPropertyValue(propertyPath, pv.getName(), pv.getValue(), beanDefinition, parentExpressionGraph, expressionGraph, beanFactory, processedBeanNames); pvs.removePropertyValue(pv.getName()); pvs.addPropertyValue(pv.getName(), newValue); } // removed expression (if exists) from parent map since the property was set on child if (parentExpressionGraph.containsKey(pv.getName())) { parentExpressionGraph.remove(pv.getName()); } } // if nested bean set expression graph to null so it is not inherited from parent definition if (StringUtils.isNotBlank(nestedPropertyName)) { pvs.addPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH, null); } // add remaining expressions from parent to expression graph for (Map.Entry<String, String> parentExpression : parentExpressionGraph.entrySet()) { String expressionPath = parentExpression.getKey(); if (StringUtils.isNotBlank(nestedPropertyName)) { expressionPath = nestedPropertyName + "." + expressionPath; } if (!expressionGraph.containsKey(expressionPath)) { expressionGraph.put(expressionPath, parentExpression.getValue()); } } if (StringUtils.isNotBlank(beanName)) { processedBeanNames.add(beanName); } }
Example 11
Source File: OriginCapablePropertyValue.java From canal with Apache License 2.0 | 4 votes |
OriginCapablePropertyValue(PropertyValue propertyValue){ this(propertyValue.getName(), propertyValue.getValue(), (PropertyOrigin) propertyValue.getAttribute(ATTRIBUTE_PROPERTY_ORIGIN)); }