我正在开发一个不可变的类。下面是我的不可变类,请告诉我它是完全不可变的,或者如果我遗漏了某些东西,或者它的不可变性无论如何都会被打破,那么请告诉我..
public final class ImmutableReminder{
private final Date remindingDate;
public ImmutableReminder (Date remindingDate) {
if(remindingDate.getTime() < System.currentTimeMillis()){
throw new IllegalArgumentException("Can not set reminder” +
“ for past time: " + remindingDate);
}
this.remindingDate = new Date(remindingDate.getTime());
}
public Date getRemindingDate() {
return (Date) remindingDate.clone();
}
}