Class RequestHttpPart
- Direct Known Subclasses:
- RequestFormParam,- RequestHeader,- RequestPathParam,- RequestQueryParam
See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionRequestHttpPart(HttpPartType partType, RestRequest request, String name, String value) Constructor.
- 
Method SummaryModifier and TypeMethodDescription<T> Optional<T>Converts this part to the specified POJO type using the requestHttpPartParserand optional schema.<T> Optional<T>Converts this part to the specified POJO type using the requestHttpPartParserand optional schema.<T> Optional<T>Converts this part to the specified POJO type using the requestHttpPartParserand optional schema.Returns the value of this parameter as a boolean.Returns the value of this parameter as aBasicBooleanPart.Returns the value of this parameter as a list from a comma-delimited string.Returns the value of this parameter as aBasicCsvArrayPart.asDate()Returns the value of this parameter as a date.Returns the value of this parameter as aBasicDatePart.Returns the value of this parameter as an integer.Returns the value of this parameter as aBasicIntegerPart.asLong()Returns the value of this parameter as a long.Returns the value of this parameter as aBasicLongPart.Matches the specified pattern against this part value.Matches the specified pattern against this part value.Matches the specified pattern against this part value.Provides the ability to perform fluent-style assertions on comma-separated string parameters.Provides the ability to perform fluent-style assertions on a date parameter.Provides the ability to perform fluent-style assertions on an integer parameter.Provides the ability to perform fluent-style assertions on a long parameter.Provides the ability to perform fluent-style assertions on this parameter.asString()Returns the value of this part as a string.Returns the value of this parameter as aBasicStringPart.Returns the value of this parameter as aBasicUriPart.Sets a default value for this part.get()If a value is present, returns the value, otherwise throwsNoSuchElementException.getName()Gets the name of this part.protected RestRequestReturns the request that created this part.getValue()Returns the value of this part.booleanReturnstrue if this part exists on the request.Return the value if present, otherwise return other.parser(HttpPartParserSession value) Specifies the part parser to use for this part.schema(HttpPartSchema value) Specifies the part schema for this part.toString()
- 
Constructor Details- 
RequestHttpPartConstructor.- Parameters:
- partType- The HTTP part type.
- request- The request object.
- name- The part name.
- value- The part value.
 
 
- 
- 
Method Details- 
schemaSpecifies the part schema for this part.Used by schema-based part parsers such as OpenApiParser.- Parameters:
- value- The part schema.
- Returns:
- This object.
 
- 
parserSpecifies the part parser to use for this part.If not specified, uses the part parser defined on the client by calling RestContext.Builder.partParser().- Parameters:
- value- The new part parser to use for this part.
 If- null ,- SimplePartParser.DEFAULTwill be used.
- Returns:
- This object.
 
- 
defSets a default value for this part.- Parameters:
- def- The default value.
- Returns:
- This object.
 
- 
getValueReturns the value of this part.- Returns:
- The value of this part.
 
- 
isPresentReturnstrue if this part exists on the request.This is a shortened form for calling asString().isPresent() .- Returns:
- true if this part exists on the request.
 
- 
getIf a value is present, returns the value, otherwise throwsNoSuchElementException.This is a shortened form for calling asString().get() .- Returns:
- The value if present.
 
- 
orElseReturn the value if present, otherwise return other.This is a shortened form for calling asString().orElse( .other )- Parameters:
- other- The value to be returned if there is no value present, may be- null .
- Returns:
- The value, if present, otherwise other.
 
- 
asStringReturns the value of this part as a string.- Returns:
- The value of this part as a string, or Optional.empty()if the part was not present.
 
- 
asConverts this part to the specified POJO type using the requestHttpPartParserand optional schema.See Complex Data Types for information on defining complex generic types of MapsandCollections.- Type Parameters:
- T- The type to convert to.
- Parameters:
- type- The type to convert to.
- args- The type parameters.
- Returns:
- The converted type, or Optional.empty()if the part is not present.
- Throws:
- BasicHttpException- If value could not be parsed.
 
- 
asConverts this part to the specified POJO type using the requestHttpPartParserand optional schema.If the specified type is an HTTP part type (extends from Header/NameValuePair), then looks for one of the following constructors:- public T(String- name , String- value );
 If it doesn't find one of those constructors, then it parses it into the specified type using the part parser. - Type Parameters:
- T- The type to convert to.
- Parameters:
- type- The type to convert to.
- Returns:
- The converted type, or Optional.empty()if the part is not present.
- Throws:
- BasicHttpException- If value could not be parsed.
 
- 
asConverts this part to the specified POJO type using the requestHttpPartParserand optional schema.If the specified type is an HTTP part type (extends from Header/NameValuePair), then looks for one of the following constructors:- public T(String- name , String- value );
 If it doesn't find one of those constructors, then it parses it into the specified type using the part parser. - Type Parameters:
- T- The type to convert to.
- Parameters:
- type- The type to convert to.
- Returns:
- The converted type, or Optional.empty()if the part is not present.
- Throws:
- BasicHttpException- If value could not be parsed.
 
- 
asMatcherMatches the specified pattern against this part value.Example:Matcher matcher =request .getHeader("Content-Type" ) .asMatcher(Pattern.compile ("application/(.*)" ));if (matcher .matches()) { StringmediaType =matcher .group(1); }- Parameters:
- pattern- The regular expression pattern to match.
- Returns:
- The matcher.
- Throws:
- BasicHttpException- If a connection error occurred.
 
- 
asMatcherMatches the specified pattern against this part value.Example:Matcher matcher =request .getHeader("Content-Type" ) .asMatcher("application/(.*)" );if (matcher .matches()) { StringmediaType =matcher .group(1); }- Parameters:
- regex- The regular expression pattern to match.
- Returns:
- The matcher.
- Throws:
- BasicHttpException- If a connection error occurred.
 
- 
asMatcherMatches the specified pattern against this part value.Example:Matcher matcher =request .getHeader("Content-Type" ) .asMatcher("application/(.*)" ,CASE_INSENSITIVE );if (matcher .matches()) { StringmediaType =matcher .group(1); }- Parameters:
- regex- The regular expression pattern to match.
- flags- Pattern match flags. See- Pattern.compile(String, int).
- Returns:
- The matcher.
- Throws:
- BasicHttpException- If a connection error occurred.
 
- 
asIntegerReturns the value of this parameter as an integer.- Returns:
- The value of this parameter as an integer, or Optional.empty()if the parameter was not present.
 
- 
asBooleanReturns the value of this parameter as a boolean.- Returns:
- The value of this parameter as a boolean, or Optional.empty()if the parameter was not present.
 
- 
asLongReturns the value of this parameter as a long.- Returns:
- The value of this parameter as a long, or Optional.empty()if the parameter was not present.
 
- 
asDateReturns the value of this parameter as a date.- Returns:
- The value of this parameter as a date, or Optional.empty()if the parameter was not present.
 
- 
asCsvArrayReturns the value of this parameter as a list from a comma-delimited string.- Returns:
- The value of this parameter as a list from a comma-delimited string, or Optional.empty()if the parameter was not present.
 
- 
asCsvArrayPartReturns the value of this parameter as aBasicCsvArrayPart.- Returns:
- The value of this parameter as a BasicCsvArrayPart, nevernull .
 
- 
asDatePartReturns the value of this parameter as aBasicDatePart.- Returns:
- The value of this parameter as a BasicDatePart, nevernull .
 
- 
asIntegerPartReturns the value of this parameter as aBasicIntegerPart.- Returns:
- The value of this parameter as a BasicIntegerPart, nevernull .
 
- 
asBooleanPartReturns the value of this parameter as aBasicBooleanPart.- Returns:
- The value of this parameter as a BasicBooleanPart, nevernull .
 
- 
asLongPartReturns the value of this parameter as aBasicLongPart.- Returns:
- The value of this parameter as a BasicLongPart, nevernull .
 
- 
asStringPartReturns the value of this parameter as aBasicStringPart.- Returns:
- The value of this parameter as a BasicStringPart, nevernull .
 
- 
asUriPartReturns the value of this parameter as aBasicUriPart.- Returns:
- The value of this parameter as a BasicUriPart, nevernull .
 
- 
assertStringProvides the ability to perform fluent-style assertions on this parameter.Examples:request .getQueryParam("foo" ) .assertString().contains("bar" );The assertion test returns the original object allowing you to chain multiple requests like so: String foo =request .getQueryParam("foo" ) .assertString().contains("bar" ) .asString().get();- Returns:
- A new fluent assertion object.
 
- 
assertIntegerProvides the ability to perform fluent-style assertions on an integer parameter.Examples:request .getQueryParam("age" ) .assertInteger().isGreaterThan(1);- Returns:
- A new fluent assertion object.
 
- 
assertLongProvides the ability to perform fluent-style assertions on a long parameter.Examples:request .getQueryParam("length" ) .assertLong().isLessThan(100000);- Returns:
- A new fluent assertion object.
 
- 
assertDateProvides the ability to perform fluent-style assertions on a date parameter.Examples:request .getQueryParam("time" ) .assertDate().isAfterNow();- Returns:
- A new fluent assertion object.
 
- 
assertCsvArrayProvides the ability to perform fluent-style assertions on comma-separated string parameters.Examples:request .getQueryParam("allow" ) .assertCsvArray().contains("GET" );- Returns:
- A new fluent assertion object.
 
- 
getRequestReturns the request that created this part.- Returns:
- The request that created this part.
 
- 
getNameGets the name of this part.- Returns:
- The name of this part, never null .
 
- 
toString
 
-