Package feign.jackson

Class JacksonIteratorDecoder

  • All Implemented Interfaces:
    feign.codec.Decoder

    public final class JacksonIteratorDecoder
    extends java.lang.Object
    implements feign.codec.Decoder
    Jackson decoder which return a closeable iterator. Returned iterator auto-close the Response when it reached json array end or failed to parse stream. If this iterator is not fetched till the end, it has to be casted to Closeable and explicity Closeable#close by the consumer.

    Example:

     
     Feign.builder()
       .decoder(JacksonIteratorDecoder.create())
       .doNotCloseAfterDecode() // Required to fetch the iterator after the response is processed, need to be close
       .target(GitHub.class, "https://api.github.com");
     interface GitHub {
      @RequestLine("GET /repos/{owner}/{repo}/contributors")
       Iterator contributors(@Param("owner") String owner, @Param("repo") String repo);
     }
     
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface feign.codec.Decoder

        feign.codec.Decoder.Default
    • Method Detail

      • decode

        public java.lang.Object decode​(feign.Response response,
                                       java.lang.reflect.Type type)
                                throws java.io.IOException
        Specified by:
        decode in interface feign.codec.Decoder
        Throws:
        java.io.IOException
      • create

        public static JacksonIteratorDecoder create​(java.lang.Iterable<com.fasterxml.jackson.databind.Module> modules)
      • create

        public static JacksonIteratorDecoder create​(com.fasterxml.jackson.databind.ObjectMapper objectMapper)