Java Code Examples for org.springframework.core.convert.TypeDescriptor#isMap()
The following examples show how to use
org.springframework.core.convert.TypeDescriptor#isMap() .
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: RelaxedDataBinder.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private void extendCollectionIfNecessary(BeanWrapper wrapper, RelaxedDataBinder.BeanPath path, int index) { String name = path.prefix(index); TypeDescriptor elementDescriptor = wrapper.getPropertyTypeDescriptor(name).getElementTypeDescriptor(); if (!elementDescriptor.isMap() && !elementDescriptor.isCollection() && !elementDescriptor.getType().equals(Object.class)) { return; } Object extend = new LinkedHashMap<String, Object>(); if (!elementDescriptor.isMap() && path.isArrayIndex(index)) { extend = new ArrayList<Object>(); } wrapper.setPropertyValue(path.prefix(index + 1), extend); }
Example 2
Source File: RelaxedDataBinder.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private void extendMapIfNecessary(BeanWrapper wrapper, RelaxedDataBinder.BeanPath path, int index) { String name = path.prefix(index); TypeDescriptor parent = wrapper.getPropertyTypeDescriptor(name); if (parent == null) { return; } TypeDescriptor descriptor = parent.getMapValueTypeDescriptor(); if (descriptor == null) { descriptor = TypeDescriptor.valueOf(Object.class); } if (!descriptor.isMap() && !descriptor.isCollection() && !descriptor.getType().equals(Object.class)) { return; } String extensionName = path.prefix(index + 1); if (wrapper.isReadableProperty(extensionName)) { Object currentValue = wrapper.getPropertyValue(extensionName); if ((descriptor.isCollection() && currentValue instanceof Collection) || (!descriptor.isCollection() && currentValue instanceof Map)) { return; } } Object extend = new LinkedHashMap<String, Object>(); if (descriptor.isCollection()) { extend = new ArrayList<Object>(); } if (descriptor.getType().equals(Object.class) && path.isLastNode(index)) { extend = BLANK; } wrapper.setPropertyValue(extensionName, extend); }
Example 3
Source File: RelaxedDataBinder.java From canal with Apache License 2.0 | 5 votes |
private void extendCollectionIfNecessary(BeanWrapper wrapper, RelaxedDataBinder.BeanPath path, int index) { String name = path.prefix(index); TypeDescriptor elementDescriptor = wrapper.getPropertyTypeDescriptor(name).getElementTypeDescriptor(); if (!elementDescriptor.isMap() && !elementDescriptor.isCollection() && !elementDescriptor.getType().equals(Object.class)) { return; } Object extend = new LinkedHashMap<String, Object>(); if (!elementDescriptor.isMap() && path.isArrayIndex(index)) { extend = new ArrayList<Object>(); } wrapper.setPropertyValue(path.prefix(index + 1), extend); }
Example 4
Source File: RelaxedDataBinder.java From canal with Apache License 2.0 | 5 votes |
private void extendMapIfNecessary(BeanWrapper wrapper, RelaxedDataBinder.BeanPath path, int index) { String name = path.prefix(index); TypeDescriptor parent = wrapper.getPropertyTypeDescriptor(name); if (parent == null) { return; } TypeDescriptor descriptor = parent.getMapValueTypeDescriptor(); if (descriptor == null) { descriptor = TypeDescriptor.valueOf(Object.class); } if (!descriptor.isMap() && !descriptor.isCollection() && !descriptor.getType().equals(Object.class)) { return; } String extensionName = path.prefix(index + 1); if (wrapper.isReadableProperty(extensionName)) { Object currentValue = wrapper.getPropertyValue(extensionName); if ((descriptor.isCollection() && currentValue instanceof Collection) || (!descriptor.isCollection() && currentValue instanceof Map)) { return; } } Object extend = new LinkedHashMap<String, Object>(); if (descriptor.isCollection()) { extend = new ArrayList<Object>(); } if (descriptor.getType().equals(Object.class) && path.isLastNode(index)) { extend = BLANK; } wrapper.setPropertyValue(extensionName, extend); }