Class Reasons

java.lang.Object
net.thauvin.erik.httpstatus.Reasons

public final class Reasons extends Object
Populates the reason phrases map from bundle properties, and implements accessor methods.
Since:
1.0
  • Method Details

    • getReasonClass

      public static Map<String,String> getReasonClass(StatusCodeClass reasonClass)
      Retrieves a map of reason phrases associated with a specific standard HTTP response class.

      The response class is determined by the first digit of the status codes provided by the StatusCodeClass. This method filters and collects those reason phrases whose status code starts with the specified class digit.

      Parameters:
      reasonClass - The StatusCodeClass enum representing the HTTP response class
      Returns:
      A map where the keys are status code strings and the values are the corresponding reason phrases
      Since:
      2.0.0
    • getReasonPhrase

      public static <T> String getReasonPhrase(T statusCode)
      Returns the reason phrase for the specified status code.
      Type Parameters:
      T - The type of the status code (String or Integer)
      Parameters:
      statusCode - The status code for which the reason phrase is to be retrieved
      Returns:
      The reason phrase or null if not match is found
    • getReasonPhrase

      public static <T> String getReasonPhrase(T statusCode, String defaultReason)
      Returns the reason phrase for the specified status code.
      Type Parameters:
      T - The type of the status code (String or Integer)
      Parameters:
      statusCode - The status code for which the reason phrase is to be retrieved
      defaultReason - The default reason phrase to return if no reason phrase is found
      Returns:
      The reason phrase, or the default reason if no match is found, or null if no default provided
    • main

      public static void main(String... args)
      Prints the reason phrase for the given status code(s).
      Parameters:
      args - The status code(s) or response class(es), prints all if none