Use EqualsVerifier to test FilterSet and remove obsolete code. #1088
This commit is contained in:
parent
e8255c208f
commit
d8c8ab3077
1
pom.xml
1
pom.xml
|
|
@ -665,7 +665,6 @@
|
|||
<regex><pattern>.*.api.DetailAST</pattern><branchRate>95</branchRate><lineRate>98</lineRate></regex>
|
||||
<regex><pattern>.*.api.FileContents</pattern><branchRate>96</branchRate><lineRate>94</lineRate></regex>
|
||||
<regex><pattern>.*.api.FileText</pattern><branchRate>50</branchRate><lineRate>59</lineRate></regex>
|
||||
<regex><pattern>.*.api.FilterSet</pattern><branchRate>83</branchRate><lineRate>80</lineRate></regex>
|
||||
<regex><pattern>.*.api.FullIdent</pattern><branchRate>83</branchRate><lineRate>96</lineRate></regex>
|
||||
<regex><pattern>.*.api.JavadocTagInfo</pattern><branchRate>25</branchRate><lineRate>77</lineRate></regex>
|
||||
<regex><pattern>.*.api.JavadocTagInfo\$.*</pattern><branchRate>0</branchRate><lineRate>8</lineRate></regex>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
package com.puppycrawl.tools.checkstyle.api;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
|
@ -49,31 +51,21 @@ public class FilterSet
|
|||
filters.remove(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Filters of the filter set.
|
||||
* @return the Filters of the filter set.
|
||||
*/
|
||||
protected Set<Filter> getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return filters.toString();
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final FilterSet filterSet = (FilterSet) o;
|
||||
return Objects.equals(filters, filterSet.filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return filters.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof FilterSet) {
|
||||
final FilterSet other = (FilterSet) object;
|
||||
return this.filters.equals(other.filters);
|
||||
}
|
||||
return false;
|
||||
return Objects.hash(filters);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ package com.puppycrawl.tools.checkstyle.filters;
|
|||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.api.FilterSet;
|
||||
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -54,4 +57,9 @@ public class FilterSetTest {
|
|||
filter.addFilter(new IntRangeFilter(3, 4));
|
||||
assertTrue("0 is in [3,4]", filter.accept(Integer.valueOf(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsAndHashCode() {
|
||||
EqualsVerifier.forClass(FilterSet.class).usingGetClass().verify();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue