Class ResultCodeCounter

java.lang.Object
com.unboundid.util.ResultCodeCounter
All Implemented Interfaces:
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 Details

    • ResultCodeCounter

      Creates a new instance of this result code counter.
  • Method Details

    • 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 List<ObjectPair<ResultCode,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.