Package com.unboundid.util
Class ResultCodeCounter
- java.lang.Object
-
- com.unboundid.util.ResultCodeCounter
-
- All Implemented Interfaces:
java.io.Serializable
@Mutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class ResultCodeCounter extends java.lang.Object implements java.io.Serializable
This class provides a utility that may be used to count operation results and categorize them based on the total number of results of each type. It also provides a method for retrieving result code counts, sorted by the number of occurrences for each.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ResultCodeCounter()
Creates a new instance of this result code counter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<ObjectPair<ResultCode,java.lang.Long>>
getCounts(boolean reset)
Retrieves a list of the result codes of each type along with their respective counts.void
increment(ResultCode resultCode)
Increments the count for the provided result code.void
increment(ResultCode resultCode, int amount)
Increments the count for the provided result code by the specified amount.void
reset()
Clears all collected data from the result code counter.
-
-
-
Constructor Detail
-
ResultCodeCounter
public ResultCodeCounter()
Creates a new instance of this result code counter.
-
-
Method Detail
-
increment
public void increment(@NotNull ResultCode resultCode)
Increments the count for the provided result code.- Parameters:
resultCode
- The result code for which to increment the count.
-
increment
public void increment(@NotNull ResultCode resultCode, int amount)
Increments the count for the provided result code by the specified amount.- Parameters:
resultCode
- The result code for which to increment the count.amount
- The amount by which to increment the count.
-
reset
public void reset()
Clears all collected data from the result code counter. Any previously-collected data will be lost.
-
getCounts
@NotNull public java.util.List<ObjectPair<ResultCode,java.lang.Long>> getCounts(boolean reset)
Retrieves a list of the result codes of each type along with their respective counts. The returned list will be sorted by number of occurrences, from most frequent to least frequent.- Parameters:
reset
- Indicates whether to clear the results after obtaining them.- Returns:
- A list of the result codes of each type along with their respective counts.
-
-