class AnnotationInjector {

    public static void inject(final Object object, final Factory factory) {
        if (object == null) {
            throw new IllegalArgumentException("object cannot be null.");
        }
        if (factory == null) {
            throw new IllegalArgumentException("factory cannot be null.");
        }
        Class<?> c = object.getClass();
        // first to all annotated public setter methods.
        for (final Method method : c.getMethods()) {
            if (method.isAnnotationPresent(InjectForRequest.class)) {
                injectIntoMethod(object, factory, method);
            }
        }
        // and then all annotated fields.
        while (c != Object.class && c != null) {
            for (final Field field : c.getDeclaredFields()) {
                if (field.isAnnotationPresent(InjectForRequest.class)) {
                    injectIntoField(object, factory, field);
                }

            }

            c = c.getSuperclass();
        }
    }

}