Class HttpParts
See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final BasicPart
Creates aBasicPart
from a name/value pair string (e.g.static final BasicPart
Creates a newBasicPart
part.static final BasicPart
Creates a newBasicPart
part with a delayed value.static final BasicBooleanPart
booleanPart
(String name, Boolean value) Creates a newBasicBooleanPart
part.static final BasicBooleanPart
booleanPart
(String name, Supplier<Boolean> value) Creates a newBasicBooleanPart
part with a delayed value.static boolean
Returnstrue if thecast(Object)
method can be used on the specified object.static NameValuePair
Utility method for converting an arbitrary object to aNameValuePair
.static final BasicCsvArrayPart
csvArrayPart
(String name, String... value) Creates a newBasicCsvArrayPart
part.static final BasicCsvArrayPart
csvArrayPart
(String name, Supplier<String[]> value) Creates a newBasicCsvArrayPart
part with a delayed value.static final BasicDatePart
datePart
(String name, ZonedDateTime value) Creates a newBasicDatePart
part.static final BasicDatePart
datePart
(String name, Supplier<ZonedDateTime> value) Creates a newBasicDatePart
part 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 BasicIntegerPart
integerPart
(String name, Integer value) Creates a newBasicIntegerPart
part.static final BasicIntegerPart
integerPart
(String name, Supplier<Integer> value) Creates a newBasicIntegerPart
part with a delayed value.static boolean
isHttpPart
(HttpPartType partType, ClassMeta<?> type) Returnstrue if the specified type is a part type.static final BasicLongPart
Creates a newBasicLongPart
part.static final BasicLongPart
Creates a newBasicLongPart
part with a delayed value.static final PartList
partList()
Instantiates a newPartList
.static PartList
Creates a newPartList
initialized with the specified name/value pairs.static final PartList
partList
(List<NameValuePair> parts) Creates a newPartList
initialized with the specified parts.static final PartList
partList
(NameValuePair... parts) Creates a newPartList
initialized with the specified parts.static final SerializedPart
serializedPart
(String name, Object value) Creates a newSerializedPart
part.static final SerializedPart
serializedPart
(String name, Supplier<?> value) Creates a newSerializedPart
part with a delayed value.static final BasicStringPart
stringPart
(String name, String value) Creates a newBasicStringPart
part.static final BasicStringPart
stringPart
(String name, Supplier<String> value) Creates a newBasicStringPart
part with a delayed value.static final BasicUriPart
Creates a newBasicUriPart
part.static final BasicUriPart
Creates a newBasicUriPart
part with a delayed value.
-
Constructor Details
-
HttpParts
public HttpParts()
-
-
Method Details
-
booleanPart
Creates a newBasicBooleanPart
part.- 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
BasicBooleanPart
object, ornull if the name or value isnull .
-
booleanPart
Creates a newBasicBooleanPart
part 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
BasicBooleanPart
object, ornull if the name or value isnull .
-
csvArrayPart
Creates a newBasicCsvArrayPart
part.- 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
BasicCsvArrayPart
object, ornull if the name or value isnull .
-
csvArrayPart
Creates a newBasicCsvArrayPart
part 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
BasicCsvArrayPart
object, ornull if the name or value isnull .
-
datePart
Creates a newBasicDatePart
part.- 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" ).ZonedDateTime
Calendar
- Anything else - Converted to
String .
- Returns:
- A new
BasicDatePart
object, ornull if the name or value isnull .
-
datePart
Creates a newBasicDatePart
part 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" ).ZonedDateTime
Calendar
- Anything else - Converted to
String .
- Returns:
- A new
BasicDatePart
object, ornull if the name or value isnull .
-
integerPart
Creates a newBasicIntegerPart
part.- 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
BasicIntegerPart
object, ornull if the name or value isnull .
-
integerPart
Creates a newBasicIntegerPart
part 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
BasicIntegerPart
object, ornull if the name or value isnull .
-
longPart
Creates a newBasicLongPart
part.- 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
BasicLongPart
object, ornull if the name or value isnull .
-
longPart
Creates a newBasicLongPart
part 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
BasicLongPart
object, ornull if the name or value isnull .
-
uriPart
Creates a newBasicUriPart
part.- 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
BasicUriPart
object, ornull if the name or value isnull .
-
uriPart
Creates a newBasicUriPart
part 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
BasicUriPart
object, ornull if the name or value isnull .
-
basicPart
Creates aBasicPart
from a name/value pair string (e.g."Foo: bar" )- Parameters:
pair
- The pair string.- Returns:
- A new
BasicPart
object.
-
basicPart
Creates a newBasicPart
part.- Parameters:
name
- The part name.value
- The part value.- Returns:
- A new
BasicPart
object.
-
basicPart
Creates a newBasicPart
part 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
BasicPart
object.
-
stringPart
Creates a newBasicStringPart
part.- 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
BasicStringPart
object, ornull if the name or value isnull .
-
stringPart
Creates a newBasicStringPart
part 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
BasicStringPart
object, ornull if the name or value isnull .
-
serializedPart
Creates a newSerializedPart
part.- Parameters:
name
- The part name.value
- The part value.
Can be any POJO.- Returns:
- A new
SerializedPart
object, nevernull .
-
serializedPart
Creates a newSerializedPart
part with a delayed value.- Parameters:
name
- The part name.value
- The part value supplier.
Can be a supplier of any POJO.- Returns:
- A new
SerializedPart
object, nevernull .
-
partList
Instantiates a newPartList
.- Returns:
- A new part list.
-
partList
Creates a newPartList
initialized 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 newPartList
initialized 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 newPartList
initialized 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.
-
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 .
-
isHttpPart
Returnstrue if the specified type is a part type.A part type extends from either
Header
orNameValuePair
or 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.
-
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 .
-
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
NameValuePair
or converted to aNameValuePair
.
-
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.
-