且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

和父母在一起

更新时间:2022-12-12 20:20:29

如果您不使用Guice,则需要做与您做的完全相同的事情...声明父构造函数需要的任何参数作为每个参数的参数以及孩子的构造函数,并将其传递给super.

You'd need to do the exact same thing you do if you weren't using Guice... declare any parameters the parent constructor requires as parameters to each child's constructor as well, and pass those to super.

因此,如果抽象父类的构造函数采用Foo,则子类的构造函数应类似于:

So if your abstract parent class's constructor takes a Foo, a child class's constructor needs to look like:

@Inject public ChildClass(Foo foo, Bar bar) {
  super(foo);
  this.bar = bar;
  ...
}