Package io.datareplication.model
Class HttpHeader
- java.lang.Object
-
- io.datareplication.model.HttpHeader
-
public final class HttpHeader extends java.lang.ObjectAn HTTP header consisting of a name and one or more values.
-
-
Field Summary
Fields Modifier and Type Field Description static @NonNull java.lang.StringAUTHORIZATIONstatic @NonNull java.lang.StringCONTENT_IDstatic @NonNull java.lang.StringCONTENT_LENGTHstatic @NonNull java.lang.StringCONTENT_TYPEstatic @NonNull java.lang.StringLAST_MODIFIEDstatic @NonNull java.lang.StringLINKstatic @NonNull java.lang.StringOPERATION_TYPE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull HttpHeaderappend(@NonNull java.lang.String value)Append a single value to this header.@NonNull HttpHeaderappend(@NonNull java.util.List<@NonNull java.lang.String> values)Append multiple value to this header.static @NonNull HttpHeadercontentLength(long contentLength)Create aContent-Lengthheader.static @NonNull HttpHeadercontentType(@NonNull ContentType contentType)Create aContent-Typeheader from the givenContentType.@NonNull java.lang.StringdisplayName()The header name with its original capitalization for prettier printing.booleanequals(java.lang.Object o)inthashCode()static @NonNull HttpHeaderlastModified(@NonNull java.time.Instant lastModified)Create aLast-Modifiedheader from the given Instant.@NonNull java.lang.Stringname()The normalized header name for case-insensitive comparisons.booleannameEquals(@NonNull java.lang.String other)Return true if the given header name refers to the same header as this one.static @NonNull HttpHeaderof(@NonNull java.lang.String name, @NonNull java.lang.String value)Create a header with the given name and single value.static @NonNull HttpHeaderof(@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.StringtoString()@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-Typeheader from the givenContentType.- Parameters:
contentType- the content type- Returns:
- the
Content-TypeHttpHeader
-
contentLength
@NonNull public static @NonNull HttpHeader contentLength(long contentLength)
Create aContent-Lengthheader.- Parameters:
contentLength- the content length value- Returns:
- the
Content-LengthHttpHeader
-
lastModified
@NonNull public static @NonNull HttpHeader lastModified(@NonNull @NonNull java.time.Instant lastModified)
Create aLast-Modifiedheader 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-ModifiedHttpHeader
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-