import java.util.UUID;
-@RequiredArgsConstructor(staticName = "of")
+@RequiredArgsConstructor
@EqualsAndHashCode(of = { "id" })
@ToString(of = { "id", "name", "shard" })
public class ChatRoomInfo
private final boolean[] isShardOwned;
private final long[] currentOffset;
private final long[] nextOffset;
- private final Map<UUID, ChatRoomInfo>[] chatrooms;
+ private final Map<UUID, ChatRoom>[] chatrooms;
private boolean running;
@Getter
Message.MessageKey key = Message.MessageKey.of(chatMessageTo.getUser(), chatMessageTo.getId());
Message message = new Message(key, offset, timestamp, chatMessageTo.getText());
- ChatRoomInfo chatRoom = chatrooms[partition].get(chatRoomId);
+ ChatRoom chatRoom = chatrooms[partition].get(chatRoomId);
KafkaChatRoomService kafkaChatRoomService =
(KafkaChatRoomService) chatRoom.getChatRoomService();
}
- private void putChatRoom(ChatRoomInfo chatRoom)
+ private void putChatRoom(ChatRoom chatRoom)
{
Integer partition = chatRoom.getShard();
UUID chatRoomId = chatRoom.getId();
package de.juplo.kafka.chat.backend.persistence.kafka;
-import de.juplo.kafka.chat.backend.domain.ChatRoom;
-import de.juplo.kafka.chat.backend.domain.ChatRoomInfo;
-import lombok.Data;
+import lombok.*;
-import java.util.UUID;
-
-@Data
+@Getter
+@Setter
+@EqualsAndHashCode
+@ToString
public class CreateChatRoomRequestTo extends AbstractTo
{
private String name;
{
final String json = """
{
- "id": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
"name": "Foo-Room!",
- "shard": 666
}""";
ObjectMapper mapper;
public void testDeserialization() throws Exception
{
CreateChatRoomRequestTo message = mapper.readValue(json, CreateChatRoomRequestTo.class);
- assertThat(message.getId()).isEqualTo("5c73531c-6fc4-426c-adcb-afc5c140a0f7");
assertThat(message.getName()).isEqualTo("Foo-Room!");
- assertThat(message.getShard()).isEqualTo(666);
}
}