Example usage for org.springframework.data.rest.webmvc.config JsonPatchHandler apply

List of usage examples for org.springframework.data.rest.webmvc.config JsonPatchHandler apply

Introduction

In this page you can find the example usage for org.springframework.data.rest.webmvc.config JsonPatchHandler apply.

Prototype

public <T> T apply(IncomingRequest request, T target) throws Exception 

Source Link

Document

Applies the body of the given IncomingRequest as patch on the given target object.

Usage

From source file:org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.java

private Object readPatch(IncomingRequest request, ObjectMapper mapper, Object existingObject) {

    try {/*from  ww  w .  j ava 2s .  co m*/

        JsonPatchHandler handler = new JsonPatchHandler(mapper, reader);
        return handler.apply(request, existingObject);

    } catch (Exception o_O) {

        if (o_O instanceof HttpMessageNotReadableException) {
            throw (HttpMessageNotReadableException) o_O;
        }

        throw new HttpMessageNotReadableException(String.format(ERROR_MESSAGE, existingObject.getClass()), o_O);
    }
}