When we create immutable classes using the Immutable objects library, how can we handle mutable members (e.g. j.u.Date)?
NOTE: this is not about the java Date class and totally related to the Immutable Objects java library which will generate some code!
Example:
@Value.Immutable
public interface MyImmutableClass {
Date creationDateTime();
}
Is there a way to override the getter, so that it returns a copy?
public Date creationDateTime() {
return new Date(creationDateTime.getTime());
}