Record Class HttpResponse
java.lang.Object
java.lang.Record
org.teleight.teleightbots.webhook.HttpResponse
public record HttpResponse(@NotNull HttpResponse.StatusCode statusCode, @NotNull String body)
extends Record
Represents an HTTP response used to respond to a webhook request.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionHttpResponse(@NotNull HttpResponse.StatusCode statusCode, @NotNull String body) Creates an instance of aHttpResponserecord class. -
Method Summary
Modifier and TypeMethodDescription@NotNull Stringbody()Returns the value of thebodyrecord component.final booleanIndicates whether some other object is "equal to" this one.static HttpResponseCreates an HTTP response with status code 500 (Internal Server Error) and the specified response body.final inthashCode()Returns a hash code value for this object.static HttpResponseCreates an HTTP response with status code 204 (No Content) and an empty body.static HttpResponseCreates an HTTP response with status code 200 (OK) and the specified response body.static HttpResponseresponse(@NotNull HttpResponse.StatusCode statusCode, @NotNull String responseBody) Creates an HTTP response with the specified status code and response body.@NotNull HttpResponse.StatusCodeReturns the value of thestatusCoderecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
HttpResponse
public HttpResponse(@NotNull @NotNull HttpResponse.StatusCode statusCode, @NotNull @NotNull String body) Creates an instance of aHttpResponserecord class.- Parameters:
statusCode- the value for thestatusCoderecord componentbody- the value for thebodyrecord component
-
-
Method Details
-
ok
Creates an HTTP response with status code 200 (OK) and the specified response body.- Parameters:
responseBody- The body of the response. Cannot be null.- Returns:
- An HttpResponse with status code 200 (OK).
-
error
Creates an HTTP response with status code 500 (Internal Server Error) and the specified response body.- Parameters:
responseBody- The body of the response. Cannot be null.- Returns:
- An HttpResponse with status code 500 (Internal Server Error).
-
noContent
Creates an HTTP response with status code 204 (No Content) and an empty body.- Returns:
- An HttpResponse with status code 204 (No Content).
-
response
public static HttpResponse response(@NotNull @NotNull HttpResponse.StatusCode statusCode, @NotNull @NotNull String responseBody) Creates an HTTP response with the specified status code and response body.- Parameters:
statusCode- The status code of the response. Cannot be null.responseBody- The body of the response. Cannot be null.- Returns:
- An HttpResponse with the specified status code and response body.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
statusCode
Returns the value of thestatusCoderecord component.- Returns:
- the value of the
statusCoderecord component
-
body
Returns the value of thebodyrecord component.- Returns:
- the value of the
bodyrecord component
-