Java pass null objects to constructor

Viewed 250

Hello is there a possibility to pass all nulls to constructor and have correctly new object created?

Lets say I have such class:

public class MobileDataReportSearchCriteria extends BaseSearchCriteria<MobileDataReport> {
    private Date reportDateFrom;
    private Date reportDateTo;
    private long opponentStationId;
    private boolean correctness;

    public MobileDataReportSearchCriteria() {
    }

public MobileDataReportSearchCriteria(Date reportDateFrom, Date reportDateTo, long opponentStationId, boolean correctness) {
    this.reportDateFrom = reportDateFrom;
    this.reportDateTo = reportDateTo;
    this.opponentStationId = opponentStationId;
    this.correctness = correctness;
}
}

and now I want to instantiate new object of this class with new MobileDataReportSearchCriteria(null, null, null, null); because those objects in business logic could be nulls. How to do that because when I do that I get NullPointerException. Thank you in advance!

0 Answers
Related