/**
* Jackson deserializer for {@link Cookie}. This is needed because in most cases we don't
* set {@link Cookie#getDomain()} property. So when jackson deserialize that json {@link Cookie#setDomain(String)}
* throws {@link NullPointerException}. This is registered with {@link CookieMixin} but you can also use it with
* your own mixin.
*
* @author Jitendra Singh
* @see CookieMixin
* @since 4.2
*/classCookieDeserializerextendsJsonDeserializer<Cookie>{@OverridepublicCookiedeserialize(JsonParser jp,DeserializationContext ctxt)throwsIOException,JsonProcessingException{ObjectMapper mapper =(ObjectMapper) jp.getCodec();JsonNode jsonNode = mapper.readTree(jp);Cookie cookie =newCookie(readJsonNode(jsonNode,"name").asText(),readJsonNode(jsonNode,"value").asText());
cookie.setComment(readJsonNode(jsonNode,"comment").asText());
cookie.setDomain(readJsonNode(jsonNode,"domain").asText());
cookie.setMaxAge(readJsonNode(jsonNode,"maxAge").asInt(-1));
cookie.setSecure(readJsonNode(jsonNode,"secure").asBoolean());
cookie.setVersion(readJsonNode(jsonNode,"version").asInt());
cookie.setPath(readJsonNode(jsonNode,"path").asText());
cookie.setHttpOnly(readJsonNode(jsonNode,"httpOnly").asBoolean());return cookie;}privateJsonNodereadJsonNode(JsonNode jsonNode,String field){return jsonNode.has(field)&&!(jsonNode.get(field)instanceofNullNode)? jsonNode.get(field):MissingNode.getInstance();}}