Package net.thauvin.erik.httpstatus
Class Reasons
java.lang.Object
net.thauvin.erik.httpstatus.Reasons
Populates the
reason phrases
map from bundle properties
, and
implements accessor methods.- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptiongetReasonClass
(StatusCodeClass reasonClass) Retrieves a map of reason phrases associated with a specific standard HTTP response class.static <T> String
getReasonPhrase
(T statusCode) Returns the reason phrase for the specified status code.static <T> String
getReasonPhrase
(T statusCode, String defaultReason) Returns the reason phrase for the specified status code.static void
Prints the reason phrase for the given status code(s).
-
Method Details
-
getReasonClass
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
- TheStatusCodeClass
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
Returns the reason phrase for the specified status code. -
getReasonPhrase
Returns the reason phrase for the specified status code.- Type Parameters:
T
- The type of the status code (String
orInteger
)- Parameters:
statusCode
- The status code for which the reason phrase is to be retrieveddefaultReason
- 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
Prints the reason phrase for the given status code(s).- Parameters:
args
- The status code(s) or response class(es), prints all if none
-