public void writeValue(final String name, final Object propertyValue, final boolean silent) { String propertyName = name; if (type != null) { // target type specified, save into target value! int dotNdx = propertyName.indexOf('.'); if (dotNdx == -1) { if (mapperFunction != null) { value = mapperFunction.apply(propertyValue); } else { value = TypeConverterManager.get().convertType(propertyValue, type); } return; } if (value == null) { value = valueInstanceCreator.apply(type); } propertyName = propertyName.substring(dotNdx + 1); } // inject into target value if (silent) { BeanUtil.declaredForcedSilent.setProperty(value, propertyName, propertyValue); } else { BeanUtil.declaredForced.setProperty(value, propertyName, propertyValue); } }
/** * 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; }
/** * 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; }