/** * Recursively navigate to return a property accessor for the nested property path. * @param propertyPath property path, which may be nested * @return a property accessor for the target bean */ @SuppressWarnings("unchecked") // avoid nested generic protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); AbstractNestablePropertyAccessor nestedPa = getNestedPropertyAccessor(nestedProperty); return nestedPa.getPropertyAccessorForPropertyPath(nestedPath); } else { return this; } }
this.customEditorsForPath.forEach((editorPath, editorHolder) -> { if (nestedProperty != null) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(editorPath); if (pos != -1) { String editorNestedProperty = editorPath.substring(0, pos);
/** * Recursively navigate to return a property accessor for the nested property path. * @param propertyPath property path, which may be nested * @return a property accessor for the target bean */ @SuppressWarnings("unchecked") // avoid nested generic protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); AbstractNestablePropertyAccessor nestedPa = getNestedPropertyAccessor(nestedProperty); return nestedPa.getPropertyAccessorForPropertyPath(nestedPath); } else { return this; } }
@Override public void setProperty(String path, String value) { int index = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(path); BeanWrapperImpl wrapper = createBeanWrapper(path, index); String key = path.substring(index + 1); wrapper.setPropertyValue(key, value); }
@Override public Object getProperty(String path) { int index = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(path); BeanWrapperImpl wrapper = createBeanWrapper(path, index); String key = path.substring(index + 1); return wrapper.getPropertyValue(key); }
this.customEditorsForPath.forEach((editorPath, editorHolder) -> { if (nestedProperty != null) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(editorPath); if (pos != -1) { String editorNestedProperty = editorPath.substring(0, pos);
int index = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(key); String prefix; String suffix;
/** * @param object the target object * @param path the path to the required field * @return The field */ private Object getNestedPath(Object object, String path) { while (StringUtils.hasText(path)) { int index = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(path); if (index < 0) { index = path.length(); } object = ReflectionTestUtils.getField(object, path.substring(0, index)); if (index < path.length()) { path = path.substring(index + 1); } else { path = ""; } } return object; }
/** * Recursively navigate to return a BeanWrapper for the nested property path. * @param propertyPath property property path, which may be nested * @return a BeanWrapper for the target bean */ protected BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); BeanWrapperImpl nestedBw = getNestedBeanWrapper(nestedProperty); return nestedBw.getBeanWrapperForPropertyPath(nestedPath); } else { return this; } }
List<String> propertyNames = new ArrayList<>(); while (true) { int index = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(expression); String nestedProperty = index != -1 ? expression.substring(0, index) : expression; nestedProperty = PropertyAccessorUtils.getPropertyName(nestedProperty);
CustomEditorHolder editorHolder = entry.getValue(); if (nestedProperty != null) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(editorPath); if (pos != -1) { String editorNestedProperty = editorPath.substring(0, pos);
/** * Recursively navigate to return a property accessor for the nested property path. * @param propertyPath property path, which may be nested * @return a property accessor for the target bean */ @SuppressWarnings("unchecked") // avoid nested generic protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); AbstractNestablePropertyAccessor nestedPa = getNestedPropertyAccessor(nestedProperty); return nestedPa.getPropertyAccessorForPropertyPath(nestedPath); } else { return this; } }
/** * Recursively navigate to return a BeanWrapper for the nested property path. * @param propertyPath property property path, which may be nested * @return a BeanWrapper for the target bean */ protected BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath) throws BeansException { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // handle nested properties recursively if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); BeanWrapperImpl nestedBw = getNestedBeanWrapper(nestedProperty); return nestedBw.getBeanWrapperForPropertyPath(nestedPath); } else { return this; } }
/** * Recursively navigate to return a BeanWrapper for the nested property path. * @param propertyPath property property path, which may be nested * @return a BeanWrapper for the target bean */ protected BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); BeanWrapperImpl nestedBw = getNestedBeanWrapper(nestedProperty); return nestedBw.getBeanWrapperForPropertyPath(nestedPath); } else { return this; } }
public static Class<?> getPropertyType(Class<?> clazz, String propertyPath) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); Class<?> nestedClazz = getPropertyType(clazz, nestedProperty); return getPropertyType(nestedClazz, nestedPath); } else { PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(clazz, propertyPath); return pd != null ? pd.getPropertyType() : null; } }
List<String> propertyNames = new ArrayList<>(); while (true) { int index = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(expression); String nestedProperty = index != -1 ? expression.substring(0, index) : expression; nestedProperty = PropertyAccessorUtils.getPropertyName(nestedProperty);
int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(editorPath); if (pos != -1) { String editorNestedProperty = editorPath.substring(0, pos);
/** * Recursively navigate to return a BeanWrapper for the nested property path. * * @param propertyPath * property property path, which may be nested * @return a BeanWrapper for the target bean */ PropertyDescriptor getPropertyDescriptorForPropertyPath(String propertyPath, Class<?> propertyType) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); PropertyDescriptor propertyDescriptor = BeanUtils.getPropertyDescriptor(propertyType, nestedProperty); // BeanWrapperImpl nestedBw = getNestedBeanWrapper(nestedProperty); return getPropertyDescriptorForPropertyPath(nestedPath, propertyDescriptor.getPropertyType()); } else { return BeanUtils.getPropertyDescriptor(propertyType, propertyPath); } }
/** * Recursively navigate to return a BeanWrapper for the nested property path. * * @param propertyPath * property property path, which may be nested * @return a BeanWrapper for the target bean */ PropertyDescriptor getPropertyDescriptorForPropertyPath(String propertyPath, Class<?> propertyType) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); PropertyDescriptor propertyDescriptor = BeanUtils.getPropertyDescriptor(propertyType, nestedProperty); // BeanWrapperImpl nestedBw = getNestedBeanWrapper(nestedProperty); return getPropertyDescriptorForPropertyPath(nestedPath, propertyDescriptor.getPropertyType()); } else { return BeanUtils.getPropertyDescriptor(propertyType, propertyPath); } }
public static boolean isPersistentProperty(SessionFactory sessionFactory, Class<?> clazz, String propertyPath) { int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath); // Handle nested properties recursively. if (pos > -1) { String nestedProperty = propertyPath.substring(0, pos); String nestedPath = propertyPath.substring(pos + 1); Class<?> nestedClazz = PropertyUtils.getPropertyType(clazz, nestedProperty); return isPersistentProperty(sessionFactory, clazz, nestedProperty) && isPersistentProperty(sessionFactory, nestedClazz, nestedPath); } else { try { ClassMetadata metadata = sessionFactory.getClassMetadata(clazz); if (metadata == null) { return false; } return metadata.getPropertyType(propertyPath) != null; } catch (HibernateException e) { return false; } } }