File tree Expand file tree Collapse file tree 9 files changed +102
-39
lines changed
biojava-core/src/main/java/org/biojava/nbio/core Expand file tree Collapse file tree 9 files changed +102
-39
lines changed Original file line number Diff line number Diff line change 3131import org .biojava .nbio .core .sequence .location .template .Location ;
3232import org .biojava .nbio .core .sequence .location .template .Point ;
3333import org .biojava .nbio .core .sequence .template .*;
34+ import org .biojava .nbio .core .util .Equals ;
3435
3536import java .io .Serializable ;
3637import java .util .ArrayList ;
@@ -269,6 +270,26 @@ public List<C> getAsList() {
269270 return compounds ;
270271 }
271272
273+
274+ public boolean equals (Object o ){
275+
276+ if (! Equals .classEqual (this , o )) {
277+ return false ;
278+ }
279+
280+ Sequence <C > other = (Sequence <C >)o ;
281+
282+ if ( original .getAsList ().size () != other .getAsList ().size ())
283+ return false ;
284+
285+ for ( int i = 0 ; i < original .getAsList ().size () ; i ++){
286+ if ( ! original .getAsList ().get (i ).equalsIgnoreCase (other .getAsList ().get (i )))
287+ return false ;
288+ }
289+
290+ return true ;
291+ }
292+
272293 @ Override
273294 public boolean equals (Sequence <C >other ){
274295 if ( original .getAsList ().size () != other .getAsList ().size ())
Original file line number Diff line number Diff line change 3131import org .biojava .nbio .core .sequence .io .template .SequenceParserInterface ;
3232import org .biojava .nbio .core .sequence .storage .SequenceAsStringHelper ;
3333import org .biojava .nbio .core .sequence .template .*;
34+ import org .biojava .nbio .core .util .Equals ;
3435
3536import java .io .BufferedReader ;
3637import java .io .File ;
@@ -219,7 +220,14 @@ public List<C> getAsList() {
219220 }
220221
221222 @ Override
222- public boolean equals (Sequence <C > other ) {
223+ public boolean equals (Object o ) {
224+
225+ if (! Equals .classEqual (this , o )) {
226+ return false ;
227+ }
228+
229+ Sequence <C > other = (Sequence <C >)o ;
230+
223231
224232 if ( other .getCompoundSet () != getCompoundSet ())
225233 return false ;
@@ -242,12 +250,6 @@ public boolean equals(Sequence<C> other) {
242250
243251 }
244252
245- @ Override
246- public int hashCode (){
247- String s = getSequenceAsString ();
248- return s .hashCode ();
249- }
250-
251253 /**
252254 *
253255 * @param bioBegin
Original file line number Diff line number Diff line change 3030import org .biojava .nbio .core .sequence .Strand ;
3131import org .biojava .nbio .core .sequence .storage .SequenceAsStringHelper ;
3232import org .biojava .nbio .core .sequence .template .*;
33+ import org .biojava .nbio .core .util .Equals ;
3334
3435import java .util .ArrayList ;
3536import java .util .Iterator ;
@@ -161,8 +162,15 @@ public SequenceView<C> getInverse() {
161162 return SequenceMixin .inverse (this );
162163 }
163164
164- @ Override
165- public boolean equals (Sequence <C > other ){
165+
166+ public boolean equals (Object o ){
167+
168+ if (! Equals .classEqual (this , o )) {
169+ return false ;
170+ }
171+
172+ Sequence <C > other = (Sequence <C >)o ;
173+
166174 if ( other .getCompoundSet () != getCompoundSet ())
167175 return false ;
168176
Original file line number Diff line number Diff line change 3636import org .biojava .nbio .core .sequence .features .FeaturesKeyWordInterface ;
3737import org .biojava .nbio .core .sequence .storage .SequenceAsStringHelper ;
3838import org .biojava .nbio .core .sequence .template .*;
39+ import org .biojava .nbio .core .util .Equals ;
3940import org .biojava .nbio .core .util .XMLHelper ;
4041import org .slf4j .Logger ;
4142import org .slf4j .LoggerFactory ;
@@ -231,10 +232,15 @@ public List<C> getAsList() {
231232 }
232233
233234 @ Override
234- public boolean equals (Sequence <C > other ){
235- if ( other .getCompoundSet () != getCompoundSet ())
235+ public boolean equals (Object o ){
236+
237+ if (! Equals .classEqual (this , o )) {
236238 return false ;
239+ }
237240
241+ Sequence <C > other = (Sequence <C >)o ;
242+ if ( other .getCompoundSet () != getCompoundSet ())
243+ return false ;
238244
239245 List <C > rawCompounds = getAsList ();
240246 List <C > otherCompounds = other .getAsList ();
@@ -248,10 +254,7 @@ public boolean equals(Sequence<C> other){
248254 if ( ! myCompound .equalsIgnoreCase (otherCompound ))
249255 return false ;
250256 }
251-
252257 return true ;
253-
254-
255258 }
256259
257260 /**
Original file line number Diff line number Diff line change @@ -85,17 +85,6 @@ public String getSequenceAsString() {
8585 return getSequenceAsString (1 , getLength (), Strand .POSITIVE );
8686 }
8787
88- public boolean equals (Sequence <C >other ){
89- if ( parsedCompounds .size () != other .getAsList ().size ())
90- return false ;
91-
92- for ( int i = 0 ; i < parsedCompounds .size () ; i ++){
93- if ( ! parsedCompounds .get (i ).equalsIgnoreCase (other .getAsList ().get (i )))
94- return false ;
95- }
96-
97- return true ;
98- }
9988
10089 /**
10190 *
Original file line number Diff line number Diff line change @@ -199,18 +199,6 @@ public boolean equals(Object o) {
199199 return false ;
200200 }
201201
202- public boolean equals (Sequence <C > o ){
203-
204- if (Equals .classEqual (this , o )) {
205- @ SuppressWarnings ("unchecked" )
206- BitSequenceReader <C > that = (BitSequenceReader <C >)o ;
207- return Equals .equal (this .accession , that .accession ) &&
208- Equals .equal (this .worker , that .worker );
209- }
210- return false ;
211-
212- }
213-
214202 /**
215203 * The logic of working with a bit has been separated out into this class
216204 * to help developers create the bit data structures without having to
Original file line number Diff line number Diff line change 2323import org .biojava .nbio .core .exceptions .CompoundNotFoundException ;
2424import org .biojava .nbio .core .sequence .AccessionID ;
2525import org .biojava .nbio .core .sequence .template .*;
26+ import org .biojava .nbio .core .util .Equals ;
2627
2728import java .util .*;
2829
@@ -322,6 +323,37 @@ public boolean equals(Sequence<C> other) {
322323 }
323324
324325
326+ public boolean equals (Sequence <C > o ) {
327+
328+
329+ if (! Equals .classEqual (this , o )) {
330+ return false ;
331+ }
332+
333+ Sequence <C > other = (Sequence <C >)o ;
334+
335+
336+ if ( other .getCompoundSet () != getCompoundSet ())
337+ return false ;
338+
339+
340+ List <C > rawCompounds = getAsList ();
341+ List <C > otherCompounds = other .getAsList ();
342+
343+ if ( rawCompounds .size () != otherCompounds .size ())
344+ return false ;
345+
346+ for (int i = 0 ; i < rawCompounds .size () ; i ++){
347+ Compound myCompound = rawCompounds .get (i );
348+ Compound otherCompound = otherCompounds .get (i );
349+ if ( ! myCompound .equalsIgnoreCase (otherCompound ))
350+ return false ;
351+ }
352+
353+ return true ;
354+ }
355+
356+
325357 @ Override
326358 public int getIndexOf (C compound ) {
327359 return SequenceMixin .indexOf (this , compound );
Original file line number Diff line number Diff line change 3737import org .biojava .nbio .core .sequence .location .SimpleLocation ;
3838import org .biojava .nbio .core .sequence .location .template .Location ;
3939import org .biojava .nbio .core .sequence .storage .ArrayListSequenceReader ;
40+ import org .biojava .nbio .core .util .Equals ;
4041import org .slf4j .Logger ;
4142import org .slf4j .LoggerFactory ;
4243
@@ -519,8 +520,14 @@ public void setCompoundSet(CompoundSet<C> compoundSet) {
519520 this .compoundSet = compoundSet ;
520521 }
521522
523+ public boolean equals (Object o ){
524+
525+ if (! Equals .classEqual (this , o )) {
526+ return false ;
527+ }
528+
529+ Sequence <C > other = (Sequence <C >)o ;
522530
523- public boolean equals (Sequence <C > other ){
524531 if ( other .getCompoundSet () != getCompoundSet ())
525532 return false ;
526533
@@ -537,7 +544,6 @@ public boolean equals(Sequence<C> other){
537544 if ( ! myCompound .equalsIgnoreCase (otherCompound ))
538545 return false ;
539546 }
540-
541547 return true ;
542548 }
543549
Original file line number Diff line number Diff line change 2626package org .biojava .nbio .core .sequence .template ;
2727
2828import org .biojava .nbio .core .sequence .AccessionID ;
29+ import org .biojava .nbio .core .util .Equals ;
2930
3031import java .util .Iterator ;
3132import java .util .List ;
@@ -71,6 +72,19 @@ public List<C> getAsList() {
7172 return SequenceMixin .toList (this );
7273 }
7374
75+
76+ public boolean equals (Object o ) {
77+
78+ if (! Equals .classEqual (this , o )) {
79+ return false ;
80+ }
81+
82+ Sequence <C > other = (Sequence <C >)o ;
83+
84+
85+ return sequence .equals (other );
86+ }
87+
7488 @ Override
7589 public boolean equals (Sequence <C > other ) {
7690 return sequence .equals (other );
You can’t perform that action at this time.
0 commit comments