Class SerializedHeader
java.lang.Object
org.apache.juneau.http.classic.header.BasicHeader
org.apache.juneau.http.classic.header.SerializedHeader
- All Implemented Interfaces:
Serializable,Header,NameValuePair
See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionSerializedHeader(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.protectedSerializedHeader(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 SerializedHeaderStatic creator.static SerializedHeaderof(String name, Object value, HttpPartSerializerSession serializer, HttpPartSchema schema, boolean skipIfEmpty) Static creator.static SerializedHeaderStatic creator with delayed value.static SerializedHeaderof(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.classic.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. Can benull . The effect is implementation-dependent — seeHttpPartSerializerSessionandHttpPartSchema.serializer- The serializer to use for serializing the value to a string value.
Can benull , in which case the value is converted directly to a string instead of being serialized.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. Can benull . The effect is implementation-dependent — seeHttpPartSerializerSessionandHttpPartSchema.serializer- The serializer to use for serializing the value to a string value.
Can benull , in which case the value is converted directly to a string instead of being serialized.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. Must not benull or aNullPointerExceptionis thrown.
-
-
Method Details
-
of
Static creator.- Parameters:
name- The header name.value- The POJO to serialize as the header value.
Can benull . The effect is implementation-dependent — seeHttpPartSerializerSessionandHttpPartSchema.- Returns:
- A new header bean. Never
null . - 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.
Can benull , in which case the value is converted directly to a string instead of being serialized.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. Never
null . - 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 . The effect is implementation-dependent — seeHttpPartSerializerSessionandHttpPartSchema.- Returns:
- A new header bean. Never
null . - 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.
Can benull , in which case the value is converted directly to a string instead of being serialized.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. Never
null . - Throws:
IllegalArgumentException- If name isnull or empty.
-
copy
Creates a copy of this object.- Overrides:
copyin classBasicHeader- Returns:
- A new copy of this object.
-
copyWith
Copies this bean and sets the serializer and schema on it.- Parameters:
serializer- The new serializer for the bean. Can benull to leave the serializer unchanged.schema- The new schema for the bean. Can benull to leave the schema unchanged.- 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.
-
getValue
- Specified by:
getValuein interfaceNameValuePair- Overrides:
getValuein classBasicHeader
-
schema
Sets the schema object that defines the format of the output.- Parameters:
value- The new value for this property. Can benull to unset the 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. Can benull (no-op).- 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. Can benull to unset the property.- Returns:
- This object.
-
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.
-