Hi Mungo On 16/09/2016 14:07, Mungo Carstairs (Staff) wrote: > I fell to wondering why Java doesn't provide things like a 'read-only' > view of a collection...thinks...you could wrap a List with a List > that overrides all update methods to throw an exception...Googled for > this...well well it is already there... > > Collections.unmodifiableList(List)
I really ought to read my mail before googling to resolve niggling discussions ;) I reached the same conclusion and put a patch together: http://issues.jalview.org/browse/JAL-2172?focusedCommentId=16044&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16044 Its not merged in because a few tests fail - but may be a better solution (and may also prove useful for the AnnotatedCollectionI containers, too !) > I'm just very surprised it doesn't get a mention in Effective Java Item > 39, which discusses defensive copying, and that it's not more widely > known (at least I've never come across it being used). I suspect it slipped through because the Collections API was not released until after the first edition, and there were other priorities for the second edition. Maybe its time for a review ! .j. _______________________________________________ Jalview-dev mailing list Jalview-dev@jalview.org http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-dev