| 1 | package net.digitaltsunami.tmeter.level; |
| 2 | |
| 3 | /** |
| 4 | * Basic threshold timer level providing three levels of granularity: |
| 5 | * <ul> |
| 6 | * <li>COURSE: Record timers at a high level. For example, recording only major |
| 7 | * tasks like Add Account. |
| 8 | * <li>MEDIUM: Record timers at a more detailed level. For example, recording |
| 9 | * sub-tasks with Add Account: Validate, Insert, Prepare Response. |
| 10 | * <li>FINE: Record timers at a detail level. For example, recording all |
| 11 | * sub-tasks within Validate Account: Validate User, Validate Address, etc. |
| 12 | * </ul> |
| 13 | * |
| 14 | * @author dhagberg |
| 15 | * |
| 16 | */ |
| 17 | public enum TimerThreshold implements TimerLevel { |
| 18 | /** |
| 19 | * Course grained timer level. If filter set at this level, only timers with |
| 20 | * this level will be recorded. |
| 21 | */ |
| 22 | COURSE, |
| 23 | /** |
| 24 | * Medium grained timer level. If filter set at this level, timers with this |
| 25 | * level and above will be recorded. |
| 26 | */ |
| 27 | MEDIUM, |
| 28 | /** |
| 29 | * Fine grained timer level. If filter set at this level, all timers with a |
| 30 | * {@link TimerThreshold} timer level will be recorded. |
| 31 | */ |
| 32 | FINE; |
| 33 | |
| 34 | @Override |
| 35 | public boolean isEnabled(TimerLevel level) { |
| 36 | return (level instanceof TimerThreshold && this.ordinal() >= ((TimerThreshold) level).ordinal()); |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public boolean isEnabled(TimerLevel... levels) { |
| 41 | for (TimerLevel level : levels) { |
| 42 | if (isEnabled(level)) { |
| 43 | return true; |
| 44 | } |
| 45 | } |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public TimerLevelType getLevelType() { |
| 51 | return TimerLevelType.THRESHOLD; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public Object getGroup() { |
| 56 | return this.getClass(); |
| 57 | } |
| 58 | |
| 59 | } |