I find @AllArgsConstructor(onConstructor = @__(@Inject))
is helpful to keep code clean when working with Google Guice. I can save the constructor code. For example:
@AllArgsConstructor(onConstructor = @__(@Inject))
public class SomeClass {
private final DependentClassOne classOne;
private final DependentClassTwo classTwo;
// ...
}
For abstract
class, I'm able to use @Inject
for constructor.
@AllArgsConstructor(onConstructor = @__(@Inject))
public abstract class AbstractParentClass {
private final DependentClassOne classOne;
}
public class ChildClass extends AbstractParentClass {
private final DependentClassTwo classTwo;
@Inject
public ChildClass(final DependentClassOne classOne, final DependentClassTwo classTwo) {
super(classOne);
this.classTwo = classTwo;
}
}
Is it possible to save the constructor code in ChildClass
by using something like @AllArgsConstructor(onConstructor = @__(@Inject))
?