refactor: Refined (simplified) `StorageStrategy`
[demos/kafka/chat] / src / main / java / de / juplo / kafka / chat / backend / persistence / storage / files / FilesStorageStrategy.java
index 9952117..1fd307f 100644 (file)
@@ -1,4 +1,4 @@
-package de.juplo.kafka.chat.backend.persistence.filestorage;
+package de.juplo.kafka.chat.backend.persistence.storage.files;
 
 import com.fasterxml.jackson.core.JsonGenerator;
 import com.fasterxml.jackson.databind.JavaType;
@@ -23,7 +23,7 @@ import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
 
 @RequiredArgsConstructor
 @Slf4j
-public class FileStorageStrategy implements StorageStrategy
+public class FilesStorageStrategy implements StorageStrategy
 {
   public static final String CHATROOMS_FILENAME = "chatrooms.json";
 
@@ -36,7 +36,7 @@ public class FileStorageStrategy implements StorageStrategy
 
 
   @Override
-  public void writeChatrooms(Flux<ChatRoom> chatroomFlux)
+  public void write(Flux<ChatRoom> chatroomFlux)
   {
     Path path = chatroomsPath();
     log.info("Writing chatrooms to {}", path);
@@ -96,7 +96,7 @@ public class FileStorageStrategy implements StorageStrategy
   }
 
   @Override
-  public Flux<ChatRoom> readChatrooms()
+  public Flux<ChatRoom> read()
   {
     JavaType type = mapper.getTypeFactory().constructType(ChatRoomTo.class);
     return Flux
@@ -110,7 +110,6 @@ public class FileStorageStrategy implements StorageStrategy
             bufferSize));
   }
 
-  @Override
   public void writeMessages(ChatRoomTo chatroomTo, Flux<Message> messageFlux)
   {
     Path path = chatroomPath(chatroomTo);
@@ -169,7 +168,6 @@ public class FileStorageStrategy implements StorageStrategy
     }
   }
 
-  @Override
   public Flux<Message> readMessages(ChatRoomTo chatroomTo)
   {
     JavaType type = mapper.getTypeFactory().constructType(MessageTo.class);