12. example
Before:
public Period(Date start, Date end) {
if (start.after(end)) {
throw new IllegralArgumentException(Start cannot be after end);
}
this.start = start;
this.end = end;
}
14. example
Before:
public Period(Date start, Date end) {
if (start.after(end)) {
throw new IllegralArgumentException(Start cannot be after end);
}
this.start = start;
this.end = end;
}
After:
public Public(Date start, Date end) {
checkArguments(start.after(end), Start cannot be after end);
this.start = start;
this.end = end;
}
17. II
Before:
public 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;
}
20. II
Before:
public 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;
}
After:
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);
}