Package discord4j.rest.http
Class JacksonReaderStrategy<T>
- java.lang.Object
-
- discord4j.rest.http.JacksonReaderStrategy<T>
-
- Type Parameters:
T
- the type of object in the read response
- All Implemented Interfaces:
ReaderStrategy<T>
public class JacksonReaderStrategy<T> extends Object implements ReaderStrategy<T>
Read a response into JSON and convert to an Object of type<Res>
using Jackson.
-
-
Constructor Summary
Constructors Constructor Description JacksonReaderStrategy(ObjectMapper objectMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRead(Class<?> type, String contentType)
Whether the given object type is supported by this reader.Mono<T>
read(Mono<ByteBuf> content, Class<T> responseType)
Read from the input message and encode to a single object.
-
-
-
Constructor Detail
-
JacksonReaderStrategy
public JacksonReaderStrategy(ObjectMapper objectMapper)
-
-
Method Detail
-
canRead
public boolean canRead(@Nullable Class<?> type, @Nullable String contentType)
Description copied from interface:ReaderStrategy
Whether the given object type is supported by this reader.- Specified by:
canRead
in interfaceReaderStrategy<T>
- Parameters:
type
- the type of object to checkcontentType
- the content type for the read- Returns:
true
if readable,false
otherwise
-
read
public Mono<T> read(Mono<ByteBuf> content, Class<T> responseType)
Description copied from interface:ReaderStrategy
Read from the input message and encode to a single object.- Specified by:
read
in interfaceReaderStrategy<T>
- Parameters:
content
- the response contentsresponseType
- the type of object in the response which must have been previously checked viaReaderStrategy.canRead(Class, String)
- Returns:
- a Mono for the resolved response, according to the given response type
-
-