Class HttpParts
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final BasicPartCreates aBasicPartfrom a name/value pair string (e.g.static final BasicPartCreates a newBasicPartpart.static final BasicPartCreates a newBasicPartpart with a delayed value.static final BasicBooleanPartbooleanPart(String name, Boolean value) Creates a newBasicBooleanPartpart.static final BasicBooleanPartbooleanPart(String name, Supplier<Boolean> value) Creates a newBasicBooleanPartpart with a delayed value.static booleanReturnstrue if thecast(Object)method can be used on the specified object.static NameValuePairUtility method for converting an arbitrary object to aNameValuePair.static final BasicCsvArrayPartcsvArrayPart(String name, String... value) Creates a newBasicCsvArrayPartpart.static final BasicCsvArrayPartcsvArrayPart(String name, Supplier<String[]> value) Creates a newBasicCsvArrayPartpart with a delayed value.static final BasicDatePartdatePart(String name, ZonedDateTime value) Creates a newBasicDatePartpart.static final BasicDatePartdatePart(String name, Supplier<ZonedDateTime> value) Creates a newBasicDatePartpart with a delayed value.static Optional<ConstructorInfo>getConstructor(ClassMeta<?> type) Returns the constructor for the specified type.getName(HttpPartType partType, ClassMeta<?> type) Returns the name of the specified part type.static final BasicIntegerPartintegerPart(String name, Integer value) Creates a newBasicIntegerPartpart.static final BasicIntegerPartintegerPart(String name, Supplier<Integer> value) Creates a newBasicIntegerPartpart with a delayed value.static booleanisHttpPart(HttpPartType partType, ClassMeta<?> type) Returnstrue if the specified type is a part type.static final BasicLongPartCreates a newBasicLongPartpart.static final BasicLongPartCreates a newBasicLongPartpart with a delayed value.static final PartListpartList()Instantiates a newPartList.static PartListCreates a newPartListinitialized with the specified name/value pairs.static final PartListpartList(List<NameValuePair> parts) Creates a newPartListinitialized with the specified parts.static final PartListpartList(NameValuePair... parts) Creates a newPartListinitialized with the specified parts.static final SerializedPartserializedPart(String name, Object value) Creates a newSerializedPartpart.static final SerializedPartserializedPart(String name, Supplier<?> value) Creates a newSerializedPartpart with a delayed value.static final BasicStringPartstringPart(String name, String value) Creates a newBasicStringPartpart.static final BasicStringPartstringPart(String name, Supplier<String> value) Creates a newBasicStringPartpart with a delayed value.static final BasicUriPartCreates a newBasicUriPartpart.static final BasicUriPartCreates a newBasicUriPartpart with a delayed value.
-
Constructor Details
-
HttpParts
public HttpParts()
-
-
Method Details
-
basicPart
Creates aBasicPartfrom a name/value pair string (e.g."Foo: bar" )- Parameters:
pair- The pair string.- Returns:
- A new
BasicPartobject.
-
basicPart
Creates a newBasicPartpart.- Parameters:
name- The part name.value- The part value.- Returns:
- A new
BasicPartobject.
-
basicPart
Creates a newBasicPartpart with a delayed value.Part value is re-evaluated on each call to
NameValuePair.getValue().- Parameters:
name- The part name.value- The part value supplier.- Returns:
- A new
BasicPartobject.
-
booleanPart
Creates a newBasicBooleanPartpart.- Parameters:
name- The part name.value- The part value.
Can be any of the following:Boolean- As-is.String- Parsed usingBoolean.parseBoolean(String).- Anything else - Converted to
String and then parsed.
- Returns:
- A new
BasicBooleanPartobject, ornull if the name or value isnull .
-
booleanPart
Creates a newBasicBooleanPartpart with a delayed value.Part value is re-evaluated on each call to
NameValuePair.getValue().- Parameters:
name- The part name.value- The part value supplier.
Can be any of the following:Boolean- As-is.String- Parsed usingBoolean.parseBoolean(String).- Anything else - Converted to
String and then parsed.
- Returns:
- A new
BasicBooleanPartobject, ornull if the name or value isnull .
-
canCast
Returnstrue if thecast(Object)method can be used on the specified object.- Parameters:
o- The object to check.- Returns:
true if thecast(Object)method can be used on the specified object.
-
cast
Utility method for converting an arbitrary object to aNameValuePair.- Parameters:
o- The object to cast or convert to aNameValuePair.- Returns:
- Either the same object cast as a
NameValuePairor converted to aNameValuePair.
-
csvArrayPart
Creates a newBasicCsvArrayPartpart.- Parameters:
name- The part name.value- The part value.
Can be any of the following:String - A comma-delimited string.String[] - A pre-parsed value.- Any other array type - Converted to
String[] . - Any
Collection- Converted toString[] . - Anything else - Converted to
String .
- Returns:
- A new
BasicCsvArrayPartobject, ornull if the name or value isnull .
-
csvArrayPart
Creates a newBasicCsvArrayPartpart with a delayed value.Part value is re-evaluated on each call to
NameValuePair.getValue().- Parameters:
name- The part name.value- The part value supplier.
Can be any of the following:String - A comma-delimited string.String[] - A pre-parsed value.- Any other array type - Converted to
String[] . - Any
Collection- Converted toString[] . - Anything else - Converted to
String .
- Returns:
- A new
BasicCsvArrayPartobject, ornull if the name or value isnull .
-
datePart
Creates a newBasicDatePartpart with a delayed value.Part value is re-evaluated on each call to
NameValuePair.getValue().- Parameters:
name- The part name.value- The part value supplier.
Can be any of the following:String - An ISO-8601 formated string (e.g."1994-10-29T19:43:31Z" ).ZonedDateTimeCalendar- Anything else - Converted to
String .
- Returns:
- A new
BasicDatePartobject, ornull if the name or value isnull .
-
datePart
Creates a newBasicDatePartpart.- Parameters:
name- The part name.value- The part value.
Can be any of the following:String - An ISO-8601 formated string (e.g."1994-10-29T19:43:31Z" ).ZonedDateTimeCalendar- Anything else - Converted to
String .
- Returns:
- A new
BasicDatePartobject, ornull if the name or value isnull .
-
getConstructor
Returns the constructor for the specified type.Looks for one of the following constructors:
public T(Stringname , Stringvalue );
- Parameters:
type- The header type to find the constructor on.- Returns:
- The constructor. Never
null .
-
getName
Returns the name of the specified part type.Gets the name from one of the following annotations:
- Parameters:
partType- The part type.type- The type to check.- Returns:
- The part name. Never
null .
-
integerPart
Creates a newBasicIntegerPartpart.- Parameters:
name- The part name.value- The part value.
Can be any of the following:Number- Converted to an integer usingNumber.intValue().String- Parsed usingInteger.parseInt(String).- Anything else - Converted to
String .
- Returns:
- A new
BasicIntegerPartobject, ornull if the name or value isnull .
-
integerPart
Creates a newBasicIntegerPartpart with a delayed value.Part value is re-evaluated on each call to
NameValuePair.getValue().- Parameters:
name- The part name.value- The part value supplier.
Can be any of the following:Number- Converted to an integer usingNumber.intValue().String- Parsed usingInteger.parseInt(String).- Anything else - Converted to
String .
- Returns:
- A new
BasicIntegerPartobject, ornull if the name or value isnull .
-
isHttpPart
Returnstrue if the specified type is a part type.A part type extends from either
HeaderorNameValuePairor is annotated withHeader,Query,FormData, orPath.- Parameters:
partType- The part type.type- The type to check.- Returns:
true if the specified type is a part type.
-
longPart
Creates a newBasicLongPartpart.- Parameters:
name- The part name.value- The part value.
Can be any of the following:Number- Converted to a long usingNumber.longValue().String- Parsed usingLong.parseLong(String).- Anything else - Converted to
String .
- Returns:
- A new
BasicLongPartobject, ornull if the name or value isnull .
-
longPart
Creates a newBasicLongPartpart with a delayed value.Part value is re-evaluated on each call to
NameValuePair.getValue().- Parameters:
name- The part name.value- The part value supplier.
Can be any of the following:Number- Converted to a long usingNumber.longValue().String- Parsed usingLong.parseLong(String).- Anything else - Converted to
String .
- Returns:
- A new
BasicLongPartobject, ornull if the name or value isnull .
-
partList
Instantiates a newPartList.- Returns:
- A new part list.
-
partList
Creates a newPartListinitialized with the specified parts.- Parameters:
parts- The parts to add to the list. Can benull .null entries are ignored.- Returns:
- A new unmodifiable instance, never
null .
-
partList
Creates a newPartListinitialized with the specified parts.- Parameters:
parts- The parts to add to the list.null entries are ignored.- Returns:
- A new unmodifiable instance, never
null .
-
partList
Creates a newPartListinitialized with the specified name/value pairs.- Parameters:
pairs- Initial list of pairs.
Must be an even number of parameters representing key/value pairs.- Returns:
- A new instance.
- Throws:
RuntimeException- If odd number of parameters were specified.
-
serializedPart
Creates a newSerializedPartpart.- Parameters:
name- The part name.value- The part value.
Can be any POJO.- Returns:
- A new
SerializedPartobject, nevernull .
-
serializedPart
Creates a newSerializedPartpart with a delayed value.- Parameters:
name- The part name.value- The part value supplier.
Can be a supplier of any POJO.- Returns:
- A new
SerializedPartobject, nevernull .
-
stringPart
Creates a newBasicStringPartpart.- Parameters:
name- The part name.value- The part value.
Can be any of the following:String- Anything else - Converted to
String then parsed.
- Returns:
- A new
BasicStringPartobject, ornull if the name or value isnull .
-
stringPart
Creates a newBasicStringPartpart with a delayed value.Part value is re-evaluated on each call to
NameValuePair.getValue().- Parameters:
name- The part name.value- The part value supplier.
Can be any of the following:String- Anything else - Converted to
String then parsed.
- Returns:
- A new
BasicStringPartobject, ornull if the name or value isnull .
-
uriPart
Creates a newBasicUriPartpart with a delayed value.Part value is re-evaluated on each call to
NameValuePair.getValue().- Parameters:
name- The header name.value- The header value supplier.
Can be any of the following:String- Anything else - Converted to
String then parsed.
- Returns:
- A new
BasicUriPartobject, ornull if the name or value isnull .
-
uriPart
Creates a newBasicUriPartpart.- Parameters:
name- The header name.value- The header value.
Can be any of the following:String- Anything else - Converted to
String then parsed.
- Returns:
- A new
BasicUriPartobject, ornull if the name or value isnull .
-