// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
//     CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
//     PaymentEventId getEventId();
// 
//     PaymentEventType getEventType();
// 
//     PaymentId getPaymentId();
// 
//     LocalDateTime getTimestamp();
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
// 
//     @Override
//     protected String getPrefix() {
//         return "PEV-%s";
//     }
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
//     @PrimaryKey
//     @Id
//     private String eventId;
//     private PaymentEventType eventType;
//     private String paymentId;
//     private LocalDateTime timestamp;
//     @Column(length = 1024)
//     private String eventData;
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
// 
//     private final ObjectMapper MAPPER;
// 
//     public JsonMapper() {
//         MAPPER = new ObjectMapper();
//         MAPPER.registerModule(new JavaTimeModule());
//         MAPPER.registerModule(new Jdk8Module());
//         MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//         MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
//     }
// 
//     public <T> T read(Object json, Class<T> tClass) {
//         return MAPPER.convertValue(json, tClass);
//     }
// 
//     public <T> String write(T model) {
//         try {
//             return MAPPER.writeValueAsString(model);
//         } catch (JsonProcessingException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
// 
// }


import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.infrastructure.persistence.repository;




@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {

    private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);

    private final EventStore eventStore;
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
//     CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
//     PaymentEventId getEventId();
// 
//     PaymentEventType getEventType();
// 
//     PaymentId getPaymentId();
// 
//     LocalDateTime getTimestamp();
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
// 
//     @Override
//     protected String getPrefix() {
//         return "PEV-%s";
//     }
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
//     @PrimaryKey
//     @Id
//     private String eventId;
//     private PaymentEventType eventType;
//     private String paymentId;
//     private LocalDateTime timestamp;
//     @Column(length = 1024)
//     private String eventData;
// }
// 
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
// 
//     private final ObjectMapper MAPPER;
// 
//     public JsonMapper() {
//         MAPPER = new ObjectMapper();
//         MAPPER.registerModule(new JavaTimeModule());
//         MAPPER.registerModule(new Jdk8Module());
//         MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//         MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
//     }
// 
//     public <T> T read(Object json, Class<T> tClass) {
//         return MAPPER.convertValue(json, tClass);
//     }
// 
//     public <T> String write(T model) {
//         try {
//             return MAPPER.writeValueAsString(model);
//         } catch (JsonProcessingException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
// 
// }


// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

package com.github.sandokandias.payments.infrastructure.persistence.repository;




@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {

    private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);

    private final EventStore eventStore;
    private final JsonMapper jsonMapper;