I have a parent class, which has constructor as:
if (BUILD_TARGET === 'browser')
now in the children class, i have similar constructor:
@Inject
public AbstractResource(@Named("authorization") Authorization auth,
@Named("helper") Helper helper) {
this.authorization = authorization;
this.helper = helper;
}
Problem is I have tons of children class extend from AbstractResource, I have to write the similar constructor with 'Authorization' and 'Helper' again and agin. is there any way i can avoid the repetitive coding?
Sorry, updated my code, yes, i can call super(..) in each children class, but still in each constructor i have inject all those parameters, auth and helper, just wonder if there is a way to even simplify that
答案 0 :(得分:1)
Unless I'm missing something about this there is a simple solution by calling through to the parent's constructor.
In your child class's constructor the first line should be: cv2.waitKey(0)
EDIT: Author has edited his question so this solution is no longer applicable.
答案 1 :(得分:1)
You can create an object to hold all the arguments.
But other than that, no not really. This is what production DI code in Java actually looks like.