Package org.apache.juneau.http.header
Class SerializedHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.SerializedHeader
- All Implemented Interfaces:
Serializable
,Cloneable
,Header
,NameValuePair
TODO
See Also:
-
Constructor Summary
ModifierConstructorDescriptionSerializedHeader
(String name, Object value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Constructor.SerializedHeader
(String name, Supplier<Object> value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Constructor with delayed value.protected
SerializedHeader
(SerializedHeader copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Creates a copy of this object.copyWith
(HttpPartSerializerSession serializer, HttpPartSchema schema) Copies this bean and sets the serializer and schema on it.getValue()
static SerializedHeader
Static creator.static SerializedHeader
of
(String name, Object value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Static creator.static SerializedHeader
Static creator with delayed value.static SerializedHeader
of
(String name, Supplier<?> value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Static creator with delayed value.schema
(HttpPartSchema value) Sets the schema object that defines the format of the output.serializer
(HttpPartSerializer value) Sets the serializer to use for serializing the value to a string value.Sets the serializer to use for serializing the value to a string value.Don't serialize this header if the value isnull or an empty string.skipIfEmpty
(boolean value) Don't serialize this header if the value isnull or an empty string.Methods inherited from class org.apache.juneau.http.header.BasicHeader
assertName, assertStringValue, asString, equals, equalsIgnoreCase, get, getElements, getName, hashCode, isNotEmpty, isPresent, of, orElse, toString
-
Constructor Details
-
SerializedHeader
public SerializedHeader(String name, Object value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Constructor.- Parameters:
name
- The HTTP header name name.value
- The POJO to serialize to the parameter value.serializer
- The serializer to use for serializing the value to a string value.schema
- The schema object that defines the format of the output.
Ifnull , defaults to the schema defined on the serializer.
If that's alsonull , defaults toHttpPartSchema.DEFAULT
.
Only used if serializer is schema-aware (e.g.OpenApiSerializer
).
Can also be aSupplier
.skipIfEmpty
- If value is a blank string, the value should return asnull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
SerializedHeader
public SerializedHeader(String name, Supplier<Object> value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Constructor with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The HTTP header name name.value
- The supplier of the POJO to serialize to the parameter value.serializer
- The serializer to use for serializing the value to a string value.schema
- The schema object that defines the format of the output.
Ifnull , defaults to the schema defined on the serializer.
If that's alsonull , defaults toHttpPartSchema.DEFAULT
.
Only used if serializer is schema-aware (e.g.OpenApiSerializer
).
Can also be aSupplier
.skipIfEmpty
- If value is a blank string, the value should return asnull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
SerializedHeader
Copy constructor.- Parameters:
copyFrom
- The object to copy.
-
-
Method Details
-
of
Static creator.- Parameters:
name
- The header name.value
- The POJO to serialize as the header value.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
of
Static creator with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The header name.value
- The supplier of the POJO to serialize as the header value.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
of
public static SerializedHeader of(String name, Object value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Static creator.- Parameters:
name
- The HTTP header name name.value
- The POJO to serialize as the header value.serializer
- The serializer to use for serializing the value to a string value.schema
- The schema object that defines the format of the output.
Ifnull , defaults to the schema defined on the serializer.
If that's alsonull , defaults toHttpPartSchema.DEFAULT
.
Only used if serializer is schema-aware (e.g.OpenApiSerializer
).
Can also be aSupplier
.skipIfEmpty
- If value is a blank string, the value should return asnull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
of
public static SerializedHeader of(String name, Supplier<?> value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Static creator with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The HTTP header name name.value
- The supplier of the POJO to serialize as the header value.serializer
- The serializer to use for serializing the value to a string value.schema
- The schema object that defines the format of the output.
Ifnull , defaults to the schema defined on the serializer.
If that's alsonull , defaults toHttpPartSchema.DEFAULT
.
Only used if serializer is schema-aware (e.g.OpenApiSerializer
).
Can also be aSupplier
.skipIfEmpty
- If value is a blank string, the value should return asnull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
copy
Creates a copy of this object.- Returns:
- A new copy of this object.
-
serializer
Sets the serializer to use for serializing the value to a string value.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
serializer
Sets the serializer to use for serializing the value to a string value.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
schema
Sets the schema object that defines the format of the output.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
copyWith
Copies this bean and sets the serializer and schema on it.- Parameters:
serializer
- The new serializer for the bean. Can benull .schema
- The new schema for the bean. Can benull .- Returns:
- Either a new bean with the serializer set, or this bean if
both values are
null or the serializer and schema were already set.
-
skipIfEmpty
Don't serialize this header if the value isnull or an empty string.- Returns:
- This object.
-
skipIfEmpty
Don't serialize this header if the value isnull or an empty string.- Parameters:
value
- The new value of this setting.- Returns:
- This object.
-
getValue
- Specified by:
getValue
in interfaceNameValuePair
- Overrides:
getValue
in classBasicHeader
-