I would like to use a builder (preferably auto-value) with Guice.
Guice can find constructors annotated with @Inject but those can be cumbersome to maintain and I would like to move to a builder pattern and have that be automatically found.
so the current way is like
class ExampleA {
...
@Inject
public ExampleA(A a, B b, ...) {
}
...
}
But I would like to be able to
@ProvidedBy(builder = Builder.class) // or some way to let know guice to know what is the thing that builds it
@AutoValue
class ExampleB {
...
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder setA(A a);
public abstract Builder setB(B a);
...
public abstract ExampleB build();
}
}
Right now the only way i can think of how to use a builder pattern with Guice is to have a provides method int he module and have all the possible inputs injected in to the method of the provides which can still be very annoying to maintain
I am open to different ideas on how to link the builder and real object.