diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 7ef2a68..7d227cf 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -47,6 +47,11 @@ public class ColumnSelection */ private List order = new ArrayList(); + /* + * an unmodifiable wrapper for order + */ + private List _uorder = Collections.unmodifiableList(order); + /** * bitfield for column selection - allows quick lookup */ @@ -97,9 +102,13 @@ public class ColumnSelection return order.isEmpty(); } + /** + * + * @return unmodifiable version of ordered list + */ public List getList() { - return order; + return _uorder; } public int size() @@ -288,14 +297,17 @@ public class ColumnSelection } /** - * Returns a list of selected columns. The list contains no duplicates but is - * not necessarily ordered. It also may include columns hidden from the - * current view. This returns a copy of the actual list, and changes to the - * copy will not affect the selection. + * Returns the list of selected columns for this column selection. + * + * The list contains no duplicates but is not necessarily ordered. It also may + * include columns hidden from the current view. + * + * The list returned is *unmodifiable*. ie you'll need to copy the list to + * process it. */ public List getSelected() { - return new ArrayList(selection.getList()); + return selection.getList(); } /**