Class SerializedHeader

java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.SerializedHeader
All Implemented Interfaces:
Serializable, Cloneable, Header, NameValuePair

public class SerializedHeader extends BasicHeader
TODO
See Also:
  • 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.
      If null, defaults to the schema defined on the serializer.
      If that's also null, defaults to HttpPartSchema.DEFAULT.
      Only used if serializer is schema-aware (e.g. OpenApiSerializer).
      Can also be a Supplier.
      skipIfEmpty - If value is a blank string, the value should return as null.
      Throws:
      IllegalArgumentException - If name is null 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.
      If null, defaults to the schema defined on the serializer.
      If that's also null, defaults to HttpPartSchema.DEFAULT.
      Only used if serializer is schema-aware (e.g. OpenApiSerializer).
      Can also be a Supplier.
      skipIfEmpty - If value is a blank string, the value should return as null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • SerializedHeader

      protected SerializedHeader(SerializedHeader copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The object to copy.
  • Method Details

    • of

      public static SerializedHeader of(String name, Object value)
      Static creator.
      Parameters:
      name - The header name.
      value - The POJO to serialize as the header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • of

      public static SerializedHeader of(String name, Supplier<?> value)
      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 be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null 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.
      If null, defaults to the schema defined on the serializer.
      If that's also null, defaults to HttpPartSchema.DEFAULT.
      Only used if serializer is schema-aware (e.g. OpenApiSerializer).
      Can also be a Supplier.
      skipIfEmpty - If value is a blank string, the value should return as null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null 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.
      If null, defaults to the schema defined on the serializer.
      If that's also null, defaults to HttpPartSchema.DEFAULT.
      Only used if serializer is schema-aware (e.g. OpenApiSerializer).
      Can also be a Supplier.
      skipIfEmpty - If value is a blank string, the value should return as null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null 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 be null.
      schema - The new schema for the bean. Can be null.
      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 is null or an empty string.
      Returns:
      This object.
    • skipIfEmpty

      public SerializedHeader skipIfEmpty(boolean value)
      Don't serialize this header if the value is null or an empty string.
      Parameters:
      value - The new value of this setting.
      Returns:
      This object.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicHeader