Period(Date start, Date end) { if (start.after(end)) { throw new IllegralArgumentException("Start cannot be after end"); } this.start = start; this.end = end; } public Public(Date start, Date end) { checkArguments(start.after(end), "Start cannot be after end"); this.start = start; this.end = end; }
Period(Date start, Date end) { if (start == null || end == null) { throw new NullPointerException("Dates cannot be null"); } if (start.after(end)) { throw new IllegralArgumentException("Start can’t be after end"); } this.start = start; this.end = end; } public Period(Date start, Date end) { this.start = checkNotNull(start, "Start cannot be null"); this.end = checkNotNull(end, "End cannot be null"); checkArgument(start.after(end), "Start cannot be after end"); }