@Test public void propertyByType_findSubType() { PropertyGetter<ArrayList> propertyGetter = new PropertyGetter<ArrayList>(); assertThat(propertyGetter.propertyByType(testInstance, ArrayList.class), nullValue()); }
public T propertyByType(Object testInstance, Class<T> type) { Class<?> clazz = testInstance.getClass(); if (isTargetSet(testInstance)) { List<Field> fields = getAllFields(new LinkedList<Field>(), clazz); for (Field field : fields) { if (type.isAssignableFrom(field.getType())) { return (T) new FieldGetter(testInstance, field).get(); } } } return null; }
PropertyGetter { public T propertyByType(Object testInstance, Class<T> type) { Class<?> clazz = testInstance.getClass(); if (isTargetSet(testInstance)) { List<Field> fields = getAllFields(new LinkedList<Field>(), clazz); for (Field field : fields) { if (type.isAssignableFrom(field.getType())) { return (T) new FieldGetter(testInstance, field).get(); } } } return null; } }
PropertyGetter { public T propertyByType(Object testInstance, Class<T> type) { Class<?> clazz = testInstance.getClass(); if (isTargetSet(testInstance)) { List<Field> fields = getAllFields(new LinkedList<Field>(), clazz); for (Field field : fields) { if (type.isAssignableFrom(field.getType())) { return (T) new FieldGetter(testInstance, field).get(); } } } return null; }  }
PropertyGetter { public T propertyByType(Object testInstance, Class<T> type) { Class<?> clazz = testInstance.getClass(); if (isTargetSet(testInstance)) { List<Field> fields = getAllFields(new LinkedList<Field>(), clazz); for (Field field : fields) { if (type.isAssignableFrom(field.getType())) { return (T) new FieldGetter(testInstance, field).get(); } } } return null; }  T propertyByType(Object testInstance, Class<T> type); static List<Field> getAllFields(List<Field> fields, Class<?> type); }
PropertyGetter { public T propertyByType(Object testInstance, Class<T> type) { Class<?> clazz = testInstance.getClass(); if (isTargetSet(testInstance)) { List<Field> fields = getAllFields(new LinkedList<Field>(), clazz); for (Field field : fields) { if (type.isAssignableFrom(field.getType())) { return (T) new FieldGetter(testInstance, field).get(); } } } return null; }  T propertyByType(Object testInstance, Class<T> type); static List<Field> getAllFields(List<Field> fields, Class<?> type);  }