JAL-2050 make SequenceFeature.score final, adjust constructor calls
[jalview.git] / src / jalview / datamodel / SequenceFeature.java
index 4df57ef..045bbbd 100755 (executable)
@@ -70,7 +70,7 @@ public class SequenceFeature implements FeatureLocationI
 
   public final String featureGroup;
 
-  public float score;
+  public final float score;
 
   public String description;
 
@@ -91,7 +91,8 @@ public class SequenceFeature implements FeatureLocationI
    */
   public SequenceFeature(SequenceFeature cpy)
   {
-    this(cpy, cpy.getBegin(), cpy.getEnd(), cpy.getFeatureGroup());
+    this(cpy, cpy.getBegin(), cpy.getEnd(), cpy.getFeatureGroup(), cpy
+            .getScore());
   }
 
   /**
@@ -127,25 +128,29 @@ public class SequenceFeature implements FeatureLocationI
   public SequenceFeature(String theType, String theDesc, int theBegin,
           int theEnd, float theScore, String group)
   {
-    this(theType, theDesc, theBegin, theEnd, group);
+    this.type = theType;
+    this.description = theDesc;
+    this.begin = theBegin;
+    this.end = theEnd;
+    this.featureGroup = group;
     this.score = theScore;
   }
 
   /**
-   * A copy constructor that allows the begin and end positions and group to be
-   * modified
+   * A copy constructor that allows the value of final fields to be 'modified'
    * 
    * @param sf
    * @param newBegin
    * @param newEnd
    * @param newGroup
+   * @param newScore
    */
   public SequenceFeature(SequenceFeature sf, int newBegin, int newEnd,
-          String newGroup)
+          String newGroup, float newScore)
   {
-    this(sf.getType(), newBegin, newEnd, newGroup);
-    score = sf.score;
-    description = sf.description;
+    this(sf.getType(), sf.getDescription(), newBegin, newEnd, newScore,
+            newGroup);
+
     if (sf.otherDetails != null)
     {
       otherDetails = new HashMap<String, Object>();
@@ -165,23 +170,6 @@ public class SequenceFeature implements FeatureLocationI
   }
 
   /**
-   * Constructor that sets the final fields type, begin, end, group
-   * 
-   * @param theType
-   * @param theBegin
-   * @param theEnd
-   * @param theGroup
-   */
-  private SequenceFeature(String theType, int theBegin, int theEnd,
-          String theGroup)
-  {
-    type = theType;
-    begin = theBegin;
-    end = theEnd;
-    featureGroup = theGroup;
-  }
-
-  /**
    * Two features are considered equal if they have the same type, group,
    * description, start, end, phase, strand, and (if present) 'Name', ID' and
    * 'Parent' attributes.
@@ -339,11 +327,6 @@ public class SequenceFeature implements FeatureLocationI
     return score;
   }
 
-  public void setScore(float value)
-  {
-    score = value;
-  }
-
   /**
    * Used for getting values which are not in the basic set. eg STRAND, PHASE
    * for GFF file