Skip to content

Commit

Permalink
Implement equals() for FeatureFilter.
Browse files Browse the repository at this point in the history
Important if we want to decide whether a filter is present in a
collection or not.
  • Loading branch information
tinevez committed Dec 12, 2024
1 parent 11147cd commit fdf59bc
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/fiji/plugin/trackmate/features/FeatureFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
package fiji.plugin.trackmate.features;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
* A helper class to store a feature filter. It is just made of 3 public fields.
* <p>
Expand Down Expand Up @@ -55,4 +58,31 @@ public String toString()
return str;
}

@Override
public boolean equals( final Object obj )
{
if ( obj == null )
return false;
if ( obj == this )
return true;
if ( obj.getClass() != getClass() )
return false;
final FeatureFilter other = ( FeatureFilter ) obj;
return new EqualsBuilder()
.append( feature, other.feature )
.append( value, other.value )
.append( isAbove, other.isAbove )
.isEquals();
}

@Override
public int hashCode()
{
return new HashCodeBuilder( 17, 37 )
.append( feature )
.append( value )
.append( isAbove )
.toHashCode();
}

}

0 comments on commit fdf59bc

Please sign in to comment.