public class ThresholdTimerLevel<E extends Enum<E>> extends Object implements TimerLevel
TimerLevel
representing a TimerLevelType.THRESHOLD
type
backed by an enumeration. Timer levels of this type are threshold and will be
active only on a match equal to or above the backing enumeration.
As an example, use of an enum of type TLevel with values: MAIN, and DETAIL.
If a CategoryTimerLevel
is created by using
enum TLevel {MAIN,DETAIL;}
public static final TimerLevel MAIN = new CategoryTimerLevel(TLevel.MAIN);
public static final TimerLevel DETAIL = new CategoryTimerLevel(TLevel.DETAIL);
Usage:
TimeTracker.enableTimerLevel(MAIN);
Timer tLogin = TimeTracker.startRecording(MAIN, "Login");
Timer tSession = TimeTracker.startRecording(DETAIL, "CheckExistingSession"); // Would not be recorded
Another method is to create an enum that extends TimerLevel
and uses
this CategoryTimerLevel to provide the implementation.
public enum TrackLevel implements TimerLevel {
MAIN(),
DETAIL();
CategoryTimerLevel timerLevel;
TrackLevel() { timerLevel = new CategoryTimerLevel(this); }
public boolean isEnabled(TimerLevel level) { return timerLevel.isEnabled(level); }
public boolean isEnabled(TimerLevel... levels) { return timerLevel.isEnabled(levels); }
public TimerLevelType getLevelType() { return timerLevel.getLevelType(); }
public Object getGroup() { return timerLevel.getGroup(); }
}
Usage:
TimeTracker.enableTimerLevel(TrackLevel.MAIN);
Timer tLogin = TimeTracker.startRecording(TrackLevel.MAIN, "Login");
Timer tSession = TimeTracker.startRecording(TrackLevel.DETAIL, "CheckExistingSession"); // Would not be recorded
Constructor and Description |
---|
ThresholdTimerLevel(E level) |
Modifier and Type | Method and Description |
---|---|
Object |
getGroup()
Return the group to which this timer level belongs.
|
TimerLevelType |
getLevelType()
Return the type of level that this level represents.
|
boolean |
isEnabled(TimerLevel... oLevels)
Compare all provided levels against this level and return true if any of
the levels is enabled for this level.
|
boolean |
isEnabled(TimerLevel oLevel)
Return true if the provided level is enabled for this level.
|
public ThresholdTimerLevel(E level)
public boolean isEnabled(TimerLevel oLevel)
TimerLevel
isEnabled
in interface TimerLevel
oLevel
- to compare against this level.public boolean isEnabled(TimerLevel... oLevels)
TimerLevel
isEnabled
in interface TimerLevel
oLevels
- list of levels to compare against this level.public TimerLevelType getLevelType()
TimerLevel
getLevelType
in interface TimerLevel
TimerLevelType
public Object getGroup()
TimerLevel
getGroup
in interface TimerLevel
Copyright © 2014. All Rights Reserved.