X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Ffeatures%2FSequenceFeatures.java;h=64aa63ecd45baa3ae4e9bc83147be9a0ed92f64f;hb=fdea751663ec46a587cfdf45bfae9ec667043efb;hp=c947407d09b7a023eaff17a56ba1255e90505c81;hpb=41cee8a4b26678d0d4c5e42e852a0b50cbc9bb2e;p=jalview.git diff --git a/src/jalview/datamodel/features/SequenceFeatures.java b/src/jalview/datamodel/features/SequenceFeatures.java index c947407..64aa63e 100644 --- a/src/jalview/datamodel/features/SequenceFeatures.java +++ b/src/jalview/datamodel/features/SequenceFeatures.java @@ -34,11 +34,14 @@ public class SequenceFeatures } /** - * Add one sequence feature to the store + * Adds one sequence feature to the store, and returns true, unless the + * feature is already contained in the store, in which case this method + * returns false. Containment is determined by SequenceFeature.equals() + * comparison. * * @param sf */ - public void add(SequenceFeature sf) + public boolean add(SequenceFeature sf) { String type = sf.getType(); @@ -46,7 +49,7 @@ public class SequenceFeatures { featureStore.put(type, new FeatureStore()); } - featureStore.get(type).addFeature(sf); + return featureStore.get(type).addFeature(sf); } /** @@ -167,4 +170,24 @@ public class SequenceFeatures } return result; } + + /** + * Deletes the given feature from the store, returning true if it was found + * (and deleted), else false. This method makes no assumption that the feature + * is in the 'expected' place in the store, in case it has been modified since + * it was added. + * + * @param sf + */ + public boolean delete(SequenceFeature sf) + { + for (FeatureStore featureSet : featureStore.values()) + { + if (featureSet.delete(sf)) + { + return true; + } + } + return false; + } }