1 package com.puppycrawl.tools.checkstyle.filters; 20 21 import com.puppycrawl.tools.checkstyle.api.AuditEvent; 22 import com.puppycrawl.tools.checkstyle.api.AutomaticBean; 23 import com.puppycrawl.tools.checkstyle.api.Filter; 24 import com.puppycrawl.tools.checkstyle.api.SeverityLevel; 25 26 32 public class SeverityMatchFilter 33 extends AutomaticBean 34 implements Filter 35 { 36 37 private SeverityLevel mSeverityLevel = SeverityLevel.ERROR; 38 39 40 private boolean mAcceptOnMatch = true; 41 42 49 public final void setSeverity(String aSeverity) 50 { 51 mSeverityLevel = SeverityLevel.getInstance(aSeverity); 52 } 53 54 59 public final void setAcceptOnMatch(boolean aAcceptOnMatch) 60 { 61 mAcceptOnMatch = aAcceptOnMatch; 62 } 63 64 65 public boolean accept(AuditEvent aEvent) 66 { 67 boolean result = mSeverityLevel.equals(aEvent.getSeverityLevel()); 68 if (mAcceptOnMatch) { 69 return result; 70 } 71 return !result; 72 } 73 } 74 | Popular Tags |