Annotation Type ClientObjectMapper


  • @Retention(RUNTIME)
    @Target(METHOD)
    public @interface ClientObjectMapper
    Used to easily define a custom object mapper for the specific REST Client on which it's used. The annotation MUST be placed on a method of the REST Client interface that meets the following criteria:
    • Is a static method
    An example method could look like the following:
     
     @ClientObjectMapper
     static ObjectMapper objectMapper() {
         return new ObjectMapper();
     }
    
     
     
    Moreover, we can inject the default ObjectMapper instance to create a copy of it by doing:
     
     @ClientObjectMapper
     static ObjectMapper objectMapper(ObjectMapper defaultObjectMapper) {
         return defaultObjectMapper.copy() <3>
                 .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
                 .disable(DeserializationFeature.UNWRAP_ROOT_VALUE);
     }
    
     
     
    Remember that the default object mapper instance should NEVER be modified, but instead always use copy if they pan to inherit the default settings.