@Override public Class classForType(SerializedType type) { return delegate.classForType(type); }
@Override public boolean test(DomainEventData<?> snapshot) { final SerializedType payloadType = snapshot.getPayload().getType(); final String payloadRevision = payloadType.getRevision(); final String aggregateRevision; try { aggregateRevision = resolver.revisionOf(serializer.classForType(payloadType)); } catch (Exception e) { // Unable to resolve a revision, ignoring this snapshot return false; } return Objects.equals(payloadRevision, aggregateRevision); } }
/** * Creates an instance which will get the supplied SerializedObject and deserialize it upon request. Use this * constructor if getting the SerializedObject is an 'expensive operation', e.g. if the SerializedObject still needs * to be upcasted. * * @param serializedObjectSupplier The supplier of the serialized object * @param serializedType The type of the serialized object * @param serializer The serializer to deserialize the payload data with */ @SuppressWarnings("unchecked") public LazyDeserializingObject(Supplier<SerializedObject<?>> serializedObjectSupplier, SerializedType serializedType, Serializer serializer) { Assert.notNull(serializedObjectSupplier, () -> "The given serializedObjectSupplier may not be null"); Assert.notNull(serializedType, () -> "The given serializedType may not be null"); Assert.notNull(serializer, () -> "The given serializer may not be null"); this.serializedObject = serializedObjectSupplier; this.serializer = serializer; this.deserializedObjectType = serializer.classForType(serializedType); }
@Override public Class classForType(SerializedType type) { return serializer.classForType(type); }
@Override public Class classForType(SerializedType type) { return delegate.classForType(type); }
private static Stream<IntermediateEventRepresentation> upcastAndDeserialize( Stream<? extends EventData<?>> eventEntryStream, Serializer serializer, EventUpcaster upcasterChain, boolean skipUnknownTypes, Function<EventData<?>, IntermediateEventRepresentation> entryConverter) { Stream<IntermediateEventRepresentation> upcastResult = upcasterChain.upcast(eventEntryStream.map(entryConverter)); if (skipUnknownTypes) { upcastResult = upcastResult.map(ir -> { try { serializer.classForType(ir.getType()); return ir; } catch (UnknownSerializedTypeException e) { return ir.upcast(SerializedType.emptyType(), byte[].class, u -> EMPTY_BYTES, Function.identity()); } }); } return upcastResult; } }
@Override public boolean test(DomainEventData<?> snapshot) { final SerializedType payloadType = snapshot.getPayload().getType(); final String payloadRevision = payloadType.getRevision(); final String aggregateRevision; try { aggregateRevision = resolver.revisionOf(serializer.classForType(payloadType)); } catch (Exception e) { // Unable to resolve a revision, ignoring this snapshot return false; } return Objects.equals(payloadRevision, aggregateRevision); } }
@Override public boolean test(DomainEventData<?> snapshot) { final SerializedType payloadType = snapshot.getPayload().getType(); final String payloadRevision = payloadType.getRevision(); final String aggregateRevision; try { aggregateRevision = resolver.revisionOf(serializer.classForType(payloadType)); } catch (Exception e) { // Unable to resolve a revision, ignoring this snapshot return false; } return Objects.equals(payloadRevision, aggregateRevision); } }
/** * Creates an instance which will get the supplied SerializedObject and deserialize it upon request. Use this * constructor if getting the SerializedObject is an 'expensive operation', e.g. if the SerializedObject still needs * to be upcasted. * * @param serializedObjectSupplier The supplier of the serialized object * @param serializedType The type of the serialized object * @param serializer The serializer to deserialize the payload data with * @throws UnknownSerializedTypeException if the type of the serialized object cannot be resolved to a class */ @SuppressWarnings("unchecked") public LazyDeserializingObject(Supplier<SerializedObject<?>> serializedObjectSupplier, SerializedType serializedType, Serializer serializer) { Assert.notNull(serializedObjectSupplier, () -> "The given serializedObjectSupplier may not be null"); Assert.notNull(serializedType, () -> "The given serializedType may not be null"); Assert.notNull(serializer, () -> "The given serializer may not be null"); this.serializedObject = serializedObjectSupplier; this.serializer = serializer; this.deserializedObjectType = serializer.classForType(serializedType); }
/** * Creates an instance which will get the supplied SerializedObject and deserialize it upon request. Use this * constructor if getting the SerializedObject is an 'expensive operation', e.g. if the SerializedObject still needs * to be upcasted. * * @param serializedObjectSupplier The supplier of the serialized object * @param serializedType The type of the serialized object * @param serializer The serializer to deserialize the payload data with */ @SuppressWarnings("unchecked") public LazyDeserializingObject(Supplier<SerializedObject<?>> serializedObjectSupplier, SerializedType serializedType, Serializer serializer) { Assert.notNull(serializedObjectSupplier, () -> "The given serializedObjectSupplier may not be null"); Assert.notNull(serializedType, () -> "The given serializedType may not be null"); Assert.notNull(serializer, () -> "The given serializer may not be null"); this.serializedObject = serializedObjectSupplier; this.serializer = serializer; this.deserializedObjectType = serializer.classForType(serializedType); }