@Test public void testCreateAndSetFieldListParam() throws Throwable { Map<String, ReflectionUtil.PropertyAccessor<?>> propertyAccessors = ReflectionUtil.getPropertyAccessors(ListBean.class); ListBean bean = new ListBean(); assertThat(bean.listField, is(nullValue())); assertThat(propertyAccessors.get("listField").handle().type().parameterType(1), equalTo(List.class)); propertyAccessors.get("listField").handle() .invoke(bean, List.of(23L, 42L)); assertThat(bean.listField, contains(23L, 42L)); }
static <T> Map<String, PropertyAccessor<?>> getPropertyAccessors(Class<T> type) { Set<String> transientProps = new HashSet<>(); Map<String, PropertyAccessor<?>> propertyAccessors = new HashMap<>(); initMethods(type, transientProps, propertyAccessors); initFields(type, transientProps, propertyAccessors); return propertyAccessors; }
ReflectionUtil { static <T> Map<String, PropertyAccessor<?>> getPropertyAccessors(Class<T> type) { Set<String> transientProps = new HashSet<>(); Map<String, PropertyAccessor<?>> propertyAccessors = new HashMap<>(); initMethods(type, transientProps, propertyAccessors); initFields(type, transientProps, propertyAccessors); return propertyAccessors; } }
ReflectionUtil { static <T> Map<String, PropertyAccessor<?>> getPropertyAccessors(Class<T> type) { Set<String> transientProps = new HashSet<>(); Map<String, PropertyAccessor<?>> propertyAccessors = new HashMap<>(); initMethods(type, transientProps, propertyAccessors); initFields(type, transientProps, propertyAccessors); return propertyAccessors; } private  ReflectionUtil(); }
ReflectionUtil { static <T> Map<String, PropertyAccessor<?>> getPropertyAccessors(Class<T> type) { Set<String> transientProps = new HashSet<>(); Map<String, PropertyAccessor<?>> propertyAccessors = new HashMap<>(); initMethods(type, transientProps, propertyAccessors); initFields(type, transientProps, propertyAccessors); return propertyAccessors; } private  ReflectionUtil();  }
ReflectionUtil { static <T> Map<String, PropertyAccessor<?>> getPropertyAccessors(Class<T> type) { Set<String> transientProps = new HashSet<>(); Map<String, PropertyAccessor<?>> propertyAccessors = new HashMap<>(); initMethods(type, transientProps, propertyAccessors); initFields(type, transientProps, propertyAccessors); return propertyAccessors; } private  ReflectionUtil();   }