by organsnyder · 11y ago · 0 comments
public class Article {
private final Author author;
...
public String getAuthor() {
return author.getName();
}
}
Also, your first class isn't fully immutable—getTags should be implemented as follows: /**
* @return Unmodifiable list of tags
*/
public List<String> getTags() {
return Collections.unmodifiableList(tags);
}True. It would be nice if Java had some immutable collection classes that don't have mutable methods. A method that gets a List<String> made with Collections.unmodifiableList(tags), doesn't know that it is actually immutable.