/** * Initializes this instance with the defaults defined in the specified * {@link InitializrMetadata}. * @param metadata the initializr metadata */ public void initialize(InitializrMetadata metadata) { BeanWrapperImpl bean = new BeanWrapperImpl(this); metadata.defaults().forEach((key, value) -> { if (bean.isWritableProperty(key)) { // We want to be able to infer a package name if none has been // explicitly set if (!key.equals("packageName")) { bean.setPropertyValue(key, value); } } }); }
if(bwrap.isWritableProperty(propPath) && (bwrap.getDefaultEditor(type)!=null|| type == String.class) && !Collection.class.isAssignableFrom(type)) {
@Override public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { BeanWrapperImpl bean = new BeanWrapperImpl(proxied); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if(pd != null) { String propertyName = pd.getName(); PropertyValue x; boolean writable = bean.isWritableProperty(propertyName); boolean readable = bean.isReadableProperty(propertyName); System.out.println(propertyName + " " + readable + " " + writable); } //return methodProxy.invokeSuper(object, args); return methodProxy.invoke(proxied, args); }
@Override public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { BeanWrapperImpl bean = new BeanWrapperImpl(proxied); PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method); if(pd != null) { String propertyName = pd.getName(); PropertyValue x; boolean writable = bean.isWritableProperty(propertyName); boolean readable = bean.isReadableProperty(propertyName); System.out.println(propertyName + " " + readable + " " + writable); } //return methodProxy.invokeSuper(object, args); return methodProxy.invoke(proxied, args); }
public T read(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { MultiValueMap<String, ?> map = delegate.read(null, inputMessage); BeanWrapperImpl beanWrapper = new BeanWrapperImpl(targetType); initBeanWrapper(beanWrapper); Map<String, Object> props = new HashMap<String, Object>(); for (String key : map.keySet()) { if (beanWrapper.isWritableProperty(key)) { List<?> list = map.get(key); props.put(key, map.get(key).size()>1 ? list : map.getFirst(key)); } } beanWrapper.setPropertyValues(props); @SuppressWarnings("unchecked") T result = (T) beanWrapper.getWrappedInstance(); return result; }
for (PropertyDescriptor pd : beanWrapper.getPropertyDescriptors()) { String name = pd.getName(); if (!beanWrapper.isWritableProperty(name)) { continue;
String propertyName = pd.getName(); boolean isReadable = beanWrapper.isReadableProperty(propertyName); boolean isWritable = beanWrapper.isWritableProperty(propertyName); if(isReadable && isWritable) { Object value = beanWrapper.getPropertyValue(propertyName);
if(bwrap.isWritableProperty(propPath) && (bwrap.getDefaultEditor(type)!=null|| type == String.class) && !Collection.class.isAssignableFrom(type)) {