code: @SuppressWarnings("unchecked")
      public static <T> void bindFactory(final AbstractBinder binder, final Injector injector, final Class<?> type,
                                         final boolean hkManaged, final boolean singleton) {
          // resolve Factory<T> actual type to bind properly
          final Class<T> res = (Class<T>) GenericsResolver.resolve(type).type(Supplier.class).generic(0);
          if (hkManaged) {
              optionalSingleton(singleton
                              ? binder.bindFactory((Class<Supplier<T>>) type, Singleton.class).to(type).to(res)
                              : binder.bindFactory((Class<Supplier<T>>) type).to(type).to(res),
                      singleton);
          } else {
              binder.bindFactory(new LazyGuiceFactory(injector, type)).to(res);
              // binding factory type to be able to autowire factory by name
              optionalSingleton(binder.bindFactory(new GuiceComponentFactory<>(injector, type)).to(type),
                      singleton);
          }
      }
docs: Binds HK2 {@link Supplier}. If bean is {@link HK2Managed} then registered directly as
  factory. Otherwise register factory through special "lazy bridge" to delay guice factory bean instantiation.
  Also registers factory directly (through wrapper to be able to inject factory by its type).
  <p>
  NOTE: since jersey 2.26 jersey don't use hk2 directly and so all HK interfaces replaced by java 8 interfaces.
  
  @param binder    HK2 binder
  @param injector  guice injector
  @param type      factory to bind
  @param hkManaged true if bean must be managed by HK2, false to bind guice managed instance
  @param singleton true to force singleton scope
  @param <T>       actual type (used to workaround type checks)
  @see ru.vyarus.dropwizard.guice.module.jersey.support.LazyGuiceFactory
  @see ru.vyarus.dropwizard.guice.module.jersey.support.GuiceComponentFactory