Package com.unboundid.util
Class ResultCodeCounter
java.lang.Object
com.unboundid.util.ResultCodeCounter
- All Implemented Interfaces:
Serializable
@Mutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class ResultCodeCounter
extends Object
implements 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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCounts(boolean reset) Retrieves a list of the result codes of each type along with their respective counts.voidincrement(ResultCode resultCode) Increments the count for the provided result code.voidincrement(ResultCode resultCode, int amount) Increments the count for the provided result code by the specified amount.voidreset()Clears all collected data from the result code counter.
-
Constructor Details
-
ResultCodeCounter
public ResultCodeCounter()Creates a new instance of this result code counter.
-
-
Method Details
-
increment
Increments the count for the provided result code.- Parameters:
resultCode- The result code for which to increment the count.
-
increment
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
Clears all collected data from the result code counter. Any previously-collected data will be lost. -
getCounts
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.
-