Class Reasons

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

public final class Reasons extends Object
Loads HTTP status reason phrases from the resource bundle and provides lookup utilities for individual status codes and status code classes.

The reason phrases are stored in a sorted, immutable map for predictable iteration order and thread‑safe access.

  • Method Details

    • getReasonClass

      public static Map<String,String> getReasonClass(StatusCodeClass reasonClass)
      Returns all reason phrases belonging to the given status code class.

      The returned map is sorted by status code.

    • getReasonPhrase

      public static String getReasonPhrase(Object statusCode)
      Returns the reason phrase for the given status code, or null if none exists.

      Accepts either an integer or string representation of the status code.

    • getReasonPhrase

      public static String getReasonPhrase(Object statusCode, String defaultReason)
      Returns the reason phrase for the given status code, or the provided default value if no phrase is defined.
    • main

      public static void main(String... args)
      Prints reason phrases for the given status code(s) or status code class(es).

      If no arguments are provided, prints all reason phrases.