/** * Partly deserializes the JSON which was given to this object's constructor. The factory method function which is * given to this method is responsible for creating the actual {@code Event}. This method receives the partly * deserialized values which can be completed by the implementor by further values if required. * * @param factoryMethodFunction creates the actual {@code Event} object. * @return the created event. * @throws NullPointerException if {@code factoryMethodFunction} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the JSON is invalid or if the event TYPE differs from the * expected one. */ public T deserialize(final FactoryMethodFunction<T> factoryMethodFunction) { checkNotNull(factoryMethodFunction, "method for creating an event object"); validateEventType(); // added in V2 for V1, fallback to revision "0": final Long revision = jsonObject.getValue(Event.JsonFields.REVISION).orElse(0L); final Instant timestamp = jsonObject.getValue(Event.JsonFields.TIMESTAMP.getPointer()) .filter(JsonValue::isString) .map(JsonValue::asString) .map(EventJsonDeserializer::tryToParseModified) .orElse(null); return factoryMethodFunction.create(revision, timestamp); }