public class SnippetCounter extends Object implements Comparable<SnippetCounter>
Modifier and Type | Class and Description |
---|---|
static class |
SnippetCounter.Group
A group of related counters.
|
Modifier and Type | Field and Description |
---|---|
private String |
description |
private SnippetCounter.Group |
group |
private static List<SnippetCounter.Group> |
groups |
private int |
index |
private String |
name |
private long |
value |
Constructor and Description |
---|
SnippetCounter(SnippetCounter.Group group,
String name,
String description)
Creates a counter.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int increment)
Increments the value of this counter.
|
int |
compareTo(SnippetCounter o)
Sorts counters in descending order of their values.
|
void |
inc()
Increments the value of this counter.
|
static void |
printGroups(PrintStream out)
Prints all the counter groups to a given stream.
|
String |
toString() |
long |
value()
Gets the value of this counter.
|
private static final List<SnippetCounter.Group> groups
private final SnippetCounter.Group group
private final int index
private final String description
private long value
public SnippetCounter(SnippetCounter.Group group, String name, String description)
group
- the group to which the counter belongs. If this is null, the newly created
counter is disabled and incrementing is a no-op.name
- the name of the counterdescription
- a brief comment describing the metric represented by the counterpublic int compareTo(SnippetCounter o)
compareTo
in interface Comparable<SnippetCounter>
public void inc()
SnippetCounter
object.public void add(int increment)
SnippetCounter
object.public long value()
public static void printGroups(PrintStream out)