Package org.apache.juneau.http.part
Class SerializedPart
java.lang.Object
org.apache.juneau.http.part.BasicPart
org.apache.juneau.http.part.SerializedPart
- All Implemented Interfaces:
NameValuePair,Headerable
Subclass of
NameValuePair for serializing POJOs as URL-encoded form post entries using the
class.
Example:
NameValuePairs
See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionSerializedPart(String name, Object value, org.apache.juneau.httppart.HttpPartType type, org.apache.juneau.httppart.HttpPartSerializerSession serializer, org.apache.juneau.httppart.HttpPartSchema schema, boolean skipIfEmpty) Constructor.protectedSerializedPart(SerializedPart copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionasHeader()Convert the object to aHeader.copy()Creates a copy of this object.copyWith(org.apache.juneau.httppart.HttpPartSerializerSession serializer, org.apache.juneau.httppart.HttpPartSchema schema) Copies this bean and sets the serializer and schema on it.getValue()static SerializedPartInstantiates a new instance of this object.static SerializedPartInstantiates a new instance of this object.schema(org.apache.juneau.httppart.HttpPartSchema value) Sets the schema object that defines the format of the output.serializer(org.apache.juneau.httppart.HttpPartSerializer value) Sets the serializer to use for serializing the value to a string value.serializer(org.apache.juneau.httppart.HttpPartSerializerSession value) Sets the serializer to use for serializing the value to a string value.Don't serialize this pair if the value isnull or an empty string.skipIfEmpty(boolean value) Don't serialize this pair if the value isnull or an empty string.type(org.apache.juneau.httppart.HttpPartType value) Sets the HTTP part type.Methods inherited from class org.apache.juneau.http.part.BasicPart
assertName, assertValue, canCast, cast, getName, getRawValue, ofPair, toString
-
Constructor Details
-
SerializedPart
public SerializedPart(String name, Object value, org.apache.juneau.httppart.HttpPartType type, org.apache.juneau.httppart.HttpPartSerializerSession serializer, org.apache.juneau.httppart.HttpPartSchema schema, boolean skipIfEmpty) Constructor.- Parameters:
name- The part name.value- The POJO to serialize to The part value.type- The HTTP part type.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).skipIfEmpty- If value is a blank string, the value should return asnull .
-
SerializedPart
Copy constructor.- Parameters:
copyFrom- The object to copy.
-
-
Method Details
-
of
Instantiates a new instance of this object.- Parameters:
name- The part name.value- The part value.
Can be any POJO.- Returns:
- A new
SerializedPartobject, nevernull .
-
of
Instantiates a new instance of this object.- Parameters:
name- The part name.value- The part value supplier.
Can be a supplier of any POJO.- Returns:
- A new
SerializedPartobject, nevernull .
-
copy
Creates a copy of this object.- Returns:
- A new copy of this object.
-
type
Sets the HTTP part type.- 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.
-
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
public SerializedPart copyWith(org.apache.juneau.httppart.HttpPartSerializerSession serializer, org.apache.juneau.httppart.HttpPartSchema schema) 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 pair if the value isnull or an empty string.- Returns:
- This object.
-
skipIfEmpty
Don't serialize this pair if the value isnull or an empty string.- Parameters:
value- The new value of this setting.- Returns:
- This object.
-
asHeader
Description copied from interface:HeaderableConvert the object to aHeader.- Specified by:
asHeaderin interfaceHeaderable- Overrides:
asHeaderin classBasicPart- Returns:
- The object converted to a
Header.
-
getValue
- Specified by:
getValuein interfaceNameValuePair- Overrides:
getValuein classBasicPart
-