/** * Sets the property value. */ private void setValue(final Object target, final PropertyDescriptor pd, Object value) throws InvocationTargetException, IllegalAccessException { Class propertyType; Setter setter = pd.getSetter(true); if (setter != null) { if (value != null) { propertyType = setter.getSetterRawType(); value = jsonParser.convertType(value, propertyType); } setter.invokeSetter(target, value); } }
/** * Creates new instance for current property name through its setter. * It uses default constructor! */ protected Object createBeanProperty(BeanProperty bp) { Setter setter = bp.getSetter(true); if (setter == null) { return null; } Class type = setter.getSetterRawType(); Object newInstance; try { newInstance = ReflectUtil.newInstance(type); } catch (Exception ex) { if (isSilent) { return null; } throw new BeanException("Invalid property: " + bp.name, bp, ex); } newInstance = invokeSetter(setter, bp, newInstance); return newInstance; }
/** * Creates new instance for current property name through its setter. * It uses default constructor! */ protected Object createBeanProperty(final BeanProperty bp) { Setter setter = bp.getSetter(true); if (setter == null) { return null; } Class type = setter.getSetterRawType(); Object newInstance; try { newInstance = ClassUtil.newInstance(type); } catch (Exception ex) { if (isSilent) { return null; } throw new BeanException("Invalid property: " + bp.name, bp, ex); } newInstance = invokeSetter(setter, bp, newInstance); return newInstance; }
/** * Invokes setter, but first converts type to match the setter type. */ protected Object invokeSetter(Setter setter, BeanProperty bp, Object value) { try { Class type = setter.getSetterRawType(); if (ReflectUtil.isTypeOf(type, Collection.class)) { Class componentType = setter.getSetterRawComponentType(); value = convertToCollection(value, type, componentType); } else { // no collections value = convertType(value, type); } setter.invokeSetter(bp.bean, value); } catch (Exception ex) { if (isSilent) { return null; } throw new BeanException("Setter failed: " + setter, ex); } return value; }
/** * Invokes setter, but first converts type to match the setter type. */ protected Object invokeSetter(final Setter setter, final BeanProperty bp, Object value) { try { final MapperFunction setterMapperFunction = setter.getMapperFunction(); if (setterMapperFunction != null) { value = setterMapperFunction.apply(value); } final Class type = setter.getSetterRawType(); if (ClassUtil.isTypeOf(type, Collection.class)) { Class componentType = setter.getSetterRawComponentType(); value = convertToCollection(value, type, componentType); } else { // no collections value = convertType(value, type); } setter.invokeSetter(bp.bean, value); } catch (Exception ex) { if (isSilent) { return null; } throw new BeanException("Setter failed: " + setter, ex); } return value; }
/** * Creates new instance for current property name through its setter. * It uses default constructor! */ protected Object createBeanProperty(final BeanProperty bp) { Setter setter = bp.getSetter(true); if (setter == null) { return null; } Class type = setter.getSetterRawType(); Object newInstance; try { newInstance = ClassUtil.newInstance(type); } catch (Exception ex) { if (isSilent) { return null; } throw new BeanException("Invalid property: " + bp.name, bp, ex); } newInstance = invokeSetter(setter, bp, newInstance); return newInstance; }
/** * Invokes setter, but first converts type to match the setter type. */ protected Object invokeSetter(final Setter setter, final BeanProperty bp, Object value) { try { final MapperFunction setterMapperFunction = setter.getMapperFunction(); if (setterMapperFunction != null) { value = setterMapperFunction.apply(value); } final Class type = setter.getSetterRawType(); if (ClassUtil.isTypeOf(type, Collection.class)) { Class componentType = setter.getSetterRawComponentType(); value = convertToCollection(value, type, componentType); } else { // no collections value = convertType(value, type); } setter.invokeSetter(bp.bean, value); } catch (Exception ex) { if (isSilent) { return null; } throw new BeanException("Setter failed: " + setter, ex); } return value; }