Class ReportType

java.lang.Object
com.comphenix.protocol.error.ReportType

public class ReportType extends Object
Represents a strongly-typed report. Subclasses should be immutable.

By convention, a report must be declared as a static field publicly accessible from the sender class.

  • Field Details

    • reportName

      protected String reportName
  • Constructor Details

    • ReportType

      public ReportType(String errorFormat)
      Construct a new report type.
      Parameters:
      errorFormat - - string used to format the underlying report.
  • Method Details

    • getMessage

      public String getMessage(Object[] parameters)
      Convert the given report to a string, using the provided parameters.
      Parameters:
      parameters - - parameters to insert, or NULL to insert nothing.
      Returns:
      The full report in string format.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSenderClass

      public static Class<?> getSenderClass(Object sender)
      Retrieve the class of the given sender.

      If the sender is already a Class, we return it.

      Parameters:
      sender - - the sender to look up.
      Returns:
      The class of the sender.
    • getReportName

      public static String getReportName(Object sender, ReportType type)
      Retrieve the full canonical name of a given report type.

      Note that the sender may be a class (for static callers), in which case it will be used directly instead of its getClass() method.

      It is thus not advisable for class classes to report reports.

      Parameters:
      sender - - the sender, or its class.
      type - - the report type.
      Returns:
      The full canonical name.
    • getReports

      public static ReportType[] getReports(Class<?> sender)
      Retrieve all publicly associated reports.
      Parameters:
      sender - - sender class.
      Returns:
      All associated reports.