Class SeverityLevelCounter
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.SeverityLevelCounter
-
- All Implemented Interfaces:
AuditListener,java.util.EventListener
public final class SeverityLevelCounter extends java.lang.Object implements AuditListener
An audit listener that counts how manyAuditEventsof a given severity have been generated.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicIntegercountKeeps track of the number of counted events.private SeverityLevellevelThe severity level to watch out for.
-
Constructor Summary
Constructors Constructor Description SeverityLevelCounter(SeverityLevel level)Creates a new counter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddError(AuditEvent event)Notify that an audit error was discovered on a specific file.voidaddException(AuditEvent event, java.lang.Throwable throwable)Notify that an exception happened while performing audit.voidauditFinished(AuditEvent event)Notify that the audit is finished.voidauditStarted(AuditEvent event)Notify that the audit is about to start.voidfileFinished(AuditEvent event)Notify that audit is finished on a specific file.voidfileStarted(AuditEvent event)Notify that audit is about to start on a specific file.intgetCount()Returns the number of counted events since audit started.
-
-
-
Field Detail
-
level
private final SeverityLevel level
The severity level to watch out for.
-
count
private final java.util.concurrent.atomic.AtomicInteger count
Keeps track of the number of counted events.
-
-
Constructor Detail
-
SeverityLevelCounter
public SeverityLevelCounter(SeverityLevel level)
Creates a new counter.- Parameters:
level- the severity level events need to have, must be non-null.- Throws:
java.lang.IllegalArgumentException- when level is null
-
-
Method Detail
-
addError
public void addError(AuditEvent event)
Description copied from interface:AuditListenerNotify that an audit error was discovered on a specific file.- Specified by:
addErrorin interfaceAuditListener- Parameters:
event- the event details
-
addException
public void addException(AuditEvent event, java.lang.Throwable throwable)
Description copied from interface:AuditListenerNotify that an exception happened while performing audit.- Specified by:
addExceptionin interfaceAuditListener- Parameters:
event- the event detailsthrowable- details of the exception
-
auditStarted
public void auditStarted(AuditEvent event)
Description copied from interface:AuditListenerNotify that the audit is about to start.- Specified by:
auditStartedin interfaceAuditListener- Parameters:
event- the event details
-
fileStarted
public void fileStarted(AuditEvent event)
Description copied from interface:AuditListenerNotify that audit is about to start on a specific file.- Specified by:
fileStartedin interfaceAuditListener- Parameters:
event- the event details
-
auditFinished
public void auditFinished(AuditEvent event)
Description copied from interface:AuditListenerNotify that the audit is finished.- Specified by:
auditFinishedin interfaceAuditListener- Parameters:
event- the event details
-
fileFinished
public void fileFinished(AuditEvent event)
Description copied from interface:AuditListenerNotify that audit is finished on a specific file.- Specified by:
fileFinishedin interfaceAuditListener- Parameters:
event- the event details
-
getCount
public int getCount()
Returns the number of counted events since audit started.- Returns:
- the number of counted events since audit started.
-
-