forked from checkstyle/checkstyle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#5879: new filter SuppressionXpathSingleFilter
- Loading branch information
1 parent
fd96d61
commit ce975bb
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.puppycrawl.tools.checkstyle.filters; | ||
|
||
import java.util.Collections; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
|
||
import com.puppycrawl.tools.checkstyle.api.*; | ||
|
||
public class SuppressionXpathSingleFilter extends AutomaticBean implements | ||
Filter, ExternalResourceHolder { | ||
|
||
/** The regexp to match check names against. */ | ||
private Pattern checkRegexp; | ||
|
||
/** The pattern for check class names. */ | ||
private String checkPattern; | ||
|
||
/** The regexp to match message names against. */ | ||
private Pattern messageRegexp; | ||
|
||
/** The pattern for message names. */ | ||
private String messagePattern; | ||
|
||
/** Module id filter. */ | ||
private String moduleId; | ||
|
||
/** Xpath query. */ | ||
private String xpathQuery; | ||
|
||
/** Set of individual suppresses. */ | ||
private FilterSet filters = new FilterSet(); | ||
|
||
public void setCheckRegexp(Pattern checkRegexp) { | ||
this.checkRegexp = checkRegexp; | ||
} | ||
|
||
public void setCheckPattern(String checkPattern) { | ||
this.checkPattern = checkPattern; | ||
} | ||
|
||
public void setMessageRegexp(Pattern messageRegexp) { | ||
this.messageRegexp = messageRegexp; | ||
} | ||
|
||
public void setMessagePattern(String messagePattern) { | ||
this.messagePattern = messagePattern; | ||
} | ||
|
||
public void setModuleId(String moduleId) { | ||
this.moduleId = moduleId; | ||
} | ||
|
||
public void setXpathQuery(String xpathQuery) { | ||
this.xpathQuery = xpathQuery; | ||
} | ||
|
||
|
||
@Override | ||
public boolean accept(AuditEvent event) { | ||
return filters.accept(event); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null || getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
final SuppressionXpathSingleFilter suppressionXpathSingleFilter = (SuppressionXpathSingleFilter) obj; | ||
return Objects.equals(filters, suppressionXpathSingleFilter.filters); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(filters); | ||
} | ||
|
||
@Override | ||
protected void finishLocalSetup() throws CheckstyleException { | ||
|
||
} | ||
|
||
@Override | ||
public Set<String> getExternalResourceLocations() { | ||
return null; | ||
} | ||
} |