break;
case Weeks:
case Days:
throw new IllegalArgumentException(INCOMPATIBLE_TIME_UNIT);
default:
throw new LibraryException(UNKNOWN_TIME_UNIT);
}
break;
case Months:
switch (another.units()) {
case Years:
this.length += another.length() * 12;
break;
case Weeks:
case Days:
throw new IllegalArgumentException(INCOMPATIBLE_TIME_UNIT);
default:
throw new LibraryException(UNKNOWN_TIME_UNIT);
}
break;
case Weeks:
switch (another.units()) {
case Days:
this.units = another.units();
this.length = this.length*7 + another.length();
break;
case Years:
case Months:
throw new IllegalArgumentException(INCOMPATIBLE_TIME_UNIT);
default:
throw new LibraryException(UNKNOWN_TIME_UNIT);
}
break;
case Days:
switch (another.units()) {
case Weeks:
this.length += another.length()*7;
break;
case Years:
case Months:
throw new IllegalArgumentException(INCOMPATIBLE_TIME_UNIT);
default:
throw new LibraryException(UNKNOWN_TIME_UNIT);
}
break;
default:
throw new LibraryException(UNKNOWN_TIME_UNIT);
}
return this;
}