I'd like too see another annotation that marks a Collection as read only.
I frequently have things like:
privatefinal List myList = new LinkedList();
/** Returns the list. Please note: this list is read-only */
public List getSomeList() {
return myList;
}
whereas the correct way of doing it would be:
Unable to find source-code formatter for language: java. Available languages are: xhtml, javascript, java, none, html, actionscript, xml, sql
public List getSomeList() {
return Collections.unmodifiableList(myList);
}
If all programmers follow the contract, it is no problem that the list is mutable. However, it would be nice to have some IDE support to avoid this error: An annotation to mark the list and an inspection like "Warning: Modification of collection marked as read-only"
Description
I'd like too see another annotation that marks a Collection as read only.
I frequently have things like:
privatefinal List myList = new LinkedList();
/** Returns the list. Please note: this list is read-only */
public List getSomeList() {
return myList;
}
whereas the correct way of doing it would be:
Unable to find source-code formatter for language: java. Available languages are: xhtml, javascript, java, none, html, actionscript, xml, sql
public List getSomeList() {
return Collections.unmodifiableList(myList);
}
If all programmers follow the contract, it is no problem that the list is mutable. However, it would be nice to have some IDE support to avoid this error: An annotation to mark the list and an inspection like "Warning: Modification of collection marked as read-only"