Utils { public static Map<String, Method> getGetters(final Class<?> type) throws IntrospectionException { Map<String, Method> getters = new HashMap<>(); BeanInfo beanInfo = Introspector.getBeanInfo(type); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { getters.put(propertyDescriptor.getName(), propertyDescriptor.getReadMethod()); } getters.remove("class"); return getters; } private  Utils(); static void checkNotNull(Object argument, String argumentName); static void checkArgument(boolean assertion, String message); static Map<String, Method> getGetters(final Class<?> type); static String formatTime(LocalDateTime time); static String formatDuration(Duration duration); static String formatErrorThreshold(final long errorThreshold); static List<P> extractPayloads(final List<? extends Record<P>> records); static Class<?> getGenericTypeNameFromTypeConverter(TypeConverter<?, ?> typeConverter, int genericTypeIndex); static final String LINE_SEPARATOR; static final String FILE_SEPARATOR; static final String JAVA_IO_TMPDIR; static final String NOT_APPLICABLE; }
@Test public void testGetGetters() throws Exception { Map<String, Method> getters = Utils.getGetters(Person.class); assertThat(getters) .hasSize(7) .containsKeys("firstName", "lastName", "age", "birthDate", "married", "gender", "marriageDate"); }