consider following code
@Getter
@Setter
@AllArgsConstructors
public class CourseGroupService {
private MathRepository mathRepository;
private BiologyRepository biologyRepository;
private PhysicalRepository physicalRepository;
private EnglishRepository englishRepository;
private AlgebraRepository algebraRepository;
private TrigonometryRepository trigonometryRepository;
private ChemistryRepository chemistryRepository;
private AnatomyRepository anatomyRepository;
private HistoryRepository historyRepository;
public CourseGroupService(
MathRepository mathRepository,
BiologyRepository biologyRepository,
PhysicalRepository physicalRepository,
EnglishRepository englishRepository,
AlgebraRepository algebraRepository,
TrigonometryRepository trigonometryRepository,
ChemistryRepository chemistryRepository,
AnatomyRepository anatomyRepository,
HistoryRepository historyRepository,
) {
this.mathRepository = mathRepository;
this.biologyRepository = biologyRepository;
this.physicalRepository = physicalRepository;
this.englishRepository = englishRepository;
this.algebraRepository = algebraRepository;
this.trigonometryRepository = trigonometryRepository;
this.chemistryRepository = chemistryRepository;
this.anatomyRepository = anatomyRepository;
this.historyRepository = historyRepository;
}
}
I want to create the constructor of this class
public class CourseService extends CourseBase {
private CourseGroupService courseGroupService;
private MathRepository mathRepository;
private BiologyRepository biologyRepository;
private PhysicalRepository physicalRepository;
private EnglishRepository englishRepository;
private AlgebraRepository algebraRepository;
private TrigonometryRepository trigonometryRepository;
private ChemistryRepository chemistryRepository;
private AnatomyRepository anatomyRepository;
private HistoryRepository historyRepository;
private CourseBaseOneRepository courseBaseOneRepository;
private CourseBaseTwoRepository courseBaseTwoRepository;
public CourseService(
CourseBaseOneRepository courseBaseOneRepository,
CourseBaseTwoRepository courseBaseTwoRepository
) {
super(courseBaseOneRepository, courseBaseTwoRepository);
this.courseGroupService = new courseGroupService (this.mathRepository,...,this.historyRepository);
}
...
}
The problem is this.mathRepository,..., this.historyRepository are not initialized. How can i initialize all this parameters without put them in the constructor. My goal is to have a constructor CourseService with 3 parameters .
How can i do this ?