Package io.datareplication.model
Class HttpHeader
- java.lang.Object
-
- io.datareplication.model.HttpHeader
-
public final class HttpHeader extends java.lang.Object
An HTTP header consisting of a name and one or more values.
-
-
Field Summary
Fields Modifier and Type Field Description static @NonNull java.lang.String
AUTHORIZATION
static @NonNull java.lang.String
CONTENT_ID
static @NonNull java.lang.String
CONTENT_LENGTH
static @NonNull java.lang.String
CONTENT_TYPE
static @NonNull java.lang.String
LAST_MODIFIED
static @NonNull java.lang.String
LINK
static @NonNull java.lang.String
OPERATION_TYPE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull HttpHeader
append(@NonNull java.lang.String value)
Append a single value to this header.@NonNull HttpHeader
append(@NonNull java.util.List<@NonNull java.lang.String> values)
Append multiple value to this header.static @NonNull HttpHeader
contentLength(long contentLength)
Create aContent-Length
header.static @NonNull HttpHeader
contentType(@NonNull ContentType contentType)
Create aContent-Type
header from the givenContentType
.@NonNull java.lang.String
displayName()
The header name with its original capitalization for prettier printing.boolean
equals(java.lang.Object o)
int
hashCode()
static @NonNull HttpHeader
lastModified(@NonNull java.time.Instant lastModified)
Create aLast-Modified
header from the given Instant.@NonNull java.lang.String
name()
The normalized header name for case-insensitive comparisons.boolean
nameEquals(@NonNull java.lang.String other)
Return true if the given header name refers to the same header as this one.static @NonNull HttpHeader
of(@NonNull java.lang.String name, @NonNull java.lang.String value)
Create a header with the given name and single value.static @NonNull HttpHeader
of(@NonNull java.lang.String name, @NonNull java.util.List<@NonNull java.lang.String> values)
Create a header with the given name and values.java.lang.String
toString()
@NonNull java.util.List<@NonNull java.lang.String>
values()
-
-
-
Field Detail
-
LAST_MODIFIED
@NonNull public static final @NonNull java.lang.String LAST_MODIFIED
- See Also:
- Constant Field Values
-
CONTENT_TYPE
@NonNull public static final @NonNull java.lang.String CONTENT_TYPE
- See Also:
- Constant Field Values
-
CONTENT_LENGTH
@NonNull public static final @NonNull java.lang.String CONTENT_LENGTH
- See Also:
- Constant Field Values
-
CONTENT_ID
@NonNull public static final @NonNull java.lang.String CONTENT_ID
- See Also:
- Constant Field Values
-
OPERATION_TYPE
@NonNull public static final @NonNull java.lang.String OPERATION_TYPE
- See Also:
- Constant Field Values
-
LINK
@NonNull public static final @NonNull java.lang.String LINK
- See Also:
- Constant Field Values
-
AUTHORIZATION
@NonNull public static final @NonNull java.lang.String AUTHORIZATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
append
@NonNull public @NonNull HttpHeader append(@NonNull @NonNull java.lang.String value)
Append a single value to this header.- Parameters:
value
- the new value to append- Returns:
- a new HttpHeader with the given value appended
-
append
@NonNull public @NonNull HttpHeader append(@NonNull @NonNull java.util.List<@NonNull java.lang.String> values)
Append multiple value to this header.- Parameters:
values
- the values to append- Returns:
- a new HttpHeader with the given values appended
-
nameEquals
public boolean nameEquals(@NonNull @NonNull java.lang.String other)
Return true if the given header name refers to the same header as this one. Since HTTP header names are case-insensitive, this performs a case-insensitive comparison between the string and this header's name.- Parameters:
other
- the string to compare to- Returns:
- true if the given string matches this header's name
-
of
@NonNull public static @NonNull HttpHeader of(@NonNull @NonNull java.lang.String name, @NonNull @NonNull java.lang.String value)
Create a header with the given name and single value.- Parameters:
name
- the header namevalue
- the single header value- Returns:
- the HttpHeader for the given name and value
-
of
@NonNull public static @NonNull HttpHeader of(@NonNull @NonNull java.lang.String name, @NonNull @NonNull java.util.List<@NonNull java.lang.String> values)
Create a header with the given name and values.- Parameters:
name
- the header namevalues
- the list of header values- Returns:
- the HttpHeader for the given name and value
-
contentType
@NonNull public static @NonNull HttpHeader contentType(@NonNull @NonNull ContentType contentType)
Create aContent-Type
header from the givenContentType
.- Parameters:
contentType
- the content type- Returns:
- the
Content-Type
HttpHeader
-
contentLength
@NonNull public static @NonNull HttpHeader contentLength(long contentLength)
Create aContent-Length
header.- Parameters:
contentLength
- the content length value- Returns:
- the
Content-Length
HttpHeader
-
lastModified
@NonNull public static @NonNull HttpHeader lastModified(@NonNull @NonNull java.time.Instant lastModified)
Create aLast-Modified
header from the given Instant. The Instant is formatted in the preferred HTTP datetime header format. Example:Wed, 04 Oct 2023 08:25:33 GMT
- Parameters:
lastModified
- the timestamp- Returns:
- the
Last-Modified
HttpHeader
-
name
@NonNull public @NonNull java.lang.String name()
The normalized header name for case-insensitive comparisons.
-
displayName
@NonNull public @NonNull java.lang.String displayName()
The header name with its original capitalization for prettier printing.
-
values
@NonNull public @NonNull java.util.List<@NonNull java.lang.String> values()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-