diff --git a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java index 38bb04ea4..aa249c13c 100644 --- a/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java +++ b/event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java @@ -43,5 +43,7 @@ public class KingsHand extends EventEmitter implements EventObserver { @Override public void timePasses(Weekday day) { + // This method is intentionally left empty because KingsHand does not handle time-based events directly. + // It serves as a placeholder to fulfill the EventObserver interface contract. } } diff --git a/filterer/src/main/java/com/iluwatar/filterer/threat/ThreatAwareSystem.java b/filterer/src/main/java/com/iluwatar/filterer/threat/ThreatAwareSystem.java index 6e9bf7af6..c0de663d3 100644 --- a/filterer/src/main/java/com/iluwatar/filterer/threat/ThreatAwareSystem.java +++ b/filterer/src/main/java/com/iluwatar/filterer/threat/ThreatAwareSystem.java @@ -30,7 +30,7 @@ import java.util.List; /** * Represents system that is aware of threats that are present in it. */ -public interface ThreatAwareSystem { +public interface ThreatAwareSystem { /** * Returns the system id. @@ -43,13 +43,13 @@ public interface ThreatAwareSystem { * Returns list of threats for this system. * @return list of threats for this system. */ - List threats(); + List threats(); /** * Returns the instance of {@link Filterer} helper interface that allows to covariantly * specify lower bound for predicate that we want to filter by. * @return an instance of {@link Filterer} helper interface. */ - Filterer filtered(); + Filterer, T> filtered(); } diff --git a/game-loop/src/test/java/com/iluwatar/gameloop/GameLoopTest.java b/game-loop/src/test/java/com/iluwatar/gameloop/GameLoopTest.java index 83c631db0..210892e6a 100644 --- a/game-loop/src/test/java/com/iluwatar/gameloop/GameLoopTest.java +++ b/game-loop/src/test/java/com/iluwatar/gameloop/GameLoopTest.java @@ -24,10 +24,9 @@ */ package com.iluwatar.gameloop; -import static org.junit.jupiter.api.Assertions.assertFalse; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertFalse; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -46,6 +45,7 @@ class GameLoopTest { gameLoop = new GameLoop() { @Override protected void processGameLoop() { + throw new UnsupportedOperationException("Not supported yet."); } }; } diff --git a/serialized-lob/src/main/java/com/iluwatar/slob/dbservice/DatabaseService.java b/serialized-lob/src/main/java/com/iluwatar/slob/dbservice/DatabaseService.java index ea54592c9..66555a849 100644 --- a/serialized-lob/src/main/java/com/iluwatar/slob/dbservice/DatabaseService.java +++ b/serialized-lob/src/main/java/com/iluwatar/slob/dbservice/DatabaseService.java @@ -92,7 +92,7 @@ public class DatabaseService { throws SQLException { try (var connection = dataSource.getConnection(); var statement = connection.createStatement()) { - if (dataTypeDb.equals("BINARY")) { + if (dataTypeDb.equals(BINARY_DATA)) { statement.execute(CREATE_BINARY_SCHEMA_DDL); } else { statement.execute(CREATE_TEXT_SCHEMA_DDL); diff --git a/serialized-lob/src/main/java/com/iluwatar/slob/lob/Forest.java b/serialized-lob/src/main/java/com/iluwatar/slob/lob/Forest.java index 1c14d55de..644dc5db7 100644 --- a/serialized-lob/src/main/java/com/iluwatar/slob/lob/Forest.java +++ b/serialized-lob/src/main/java/com/iluwatar/slob/lob/Forest.java @@ -37,16 +37,17 @@ import lombok.NoArgsConstructor; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; - /** * Creates an object Forest which contains animals and plants as its constituents. Animals may eat * plants or other animals in the forest. */ + + @Data @NoArgsConstructor @AllArgsConstructor public class Forest implements Serializable { - + public static final String HORIZONTAL_DIVIDER = "\n--------------------------\n"; private String name; private Set animals = new HashSet<>(); private Set plants = new HashSet<>(); @@ -105,16 +106,16 @@ public class Forest implements Serializable { sb.append("Forest Name = ").append(name).append("\n"); sb.append("Animals found in the ").append(name).append(" Forest: \n"); for (Animal animal : animals) { - sb.append("\n--------------------------\n"); + sb.append(HORIZONTAL_DIVIDER); sb.append(animal.toString()); - sb.append("\n--------------------------\n"); + sb.append(HORIZONTAL_DIVIDER); } sb.append("\n"); sb.append("Plants in the ").append(name).append(" Forest: \n"); for (Plant plant : plants) { - sb.append("\n--------------------------\n"); + sb.append(HORIZONTAL_DIVIDER); sb.append(plant.toString()); - sb.append("\n--------------------------\n"); + sb.append(HORIZONTAL_DIVIDER); } return sb.toString(); } diff --git a/server-session/src/test/java/com.iluwatar.sessionserver/LoginHandlerTest.java b/server-session/src/test/java/com/iluwatar/sessionserver/LoginHandlerTest.java similarity index 100% rename from server-session/src/test/java/com.iluwatar.sessionserver/LoginHandlerTest.java rename to server-session/src/test/java/com/iluwatar/sessionserver/LoginHandlerTest.java diff --git a/server-session/src/test/java/com.iluwatar.sessionserver/LogoutHandlerTest.java b/server-session/src/test/java/com/iluwatar/sessionserver/LogoutHandlerTest.java similarity index 100% rename from server-session/src/test/java/com.iluwatar.sessionserver/LogoutHandlerTest.java rename to server-session/src/test/java/com/iluwatar/sessionserver/LogoutHandlerTest.java diff --git a/type-object/src/main/java/com/iluwatar/typeobject/App.java b/type-object/src/main/java/com/iluwatar/typeobject/App.java index d120baca0..02058f05f 100644 --- a/type-object/src/main/java/com/iluwatar/typeobject/App.java +++ b/type-object/src/main/java/com/iluwatar/typeobject/App.java @@ -1,5 +1,6 @@ /* - * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * This project is licensed under the MIT license. Module model-view-viewmodel + * is using ZK framework licensed under LGPL (see lgpl-3.0.txt). * * The MIT License * Copyright © 2014-2022 Ilkka Seppälä @@ -27,12 +28,12 @@ package com.iluwatar.typeobject; import lombok.extern.slf4j.Slf4j; /** - *

Type object pattern is the pattern we use when the OOP concept of creating a base class and + * Type object pattern is the pattern we use when the OOP concept of creating a base class and * inheriting from it just doesn't work for the case in hand. This happens when we either don't know * what types we will need upfront, or want to be able to modify or add new types conveniently w/o * recompiling repeatedly. The pattern provides a solution by allowing flexible creation of required - * objects by creating one class, which has a field which represents the 'type' of the object.

- *

In this example, we have a mini candy-crush game in action. There are many different candies + * objects by creating one class, which has a field which represents the 'type' of the object. + * In this example, we have a mini candy-crush game in action. There are many different candies * in the game, which may change over time, as we may want to upgrade the game. To make the object * creation convenient, we have a class {@link Candy} which has a field name, parent, points and * Type. We have a json file {@link candy} which contains the details about the candies, and this is @@ -41,7 +42,7 @@ import lombok.extern.slf4j.Slf4j; * how crushing can be done, how the matrix is to be reconfigured and how points are to be gained. * The {@link CellPool} class is a pool which reuses the candy cells that have been crushed instead * of making new ones repeatedly. The {@link CandyGame} class has the rules for the continuation of - * the game and the {@link App} class has the game itself.

+ * the game and the {@link App} class has the game itself. */ @Slf4j diff --git a/type-object/src/main/java/com/iluwatar/typeobject/CandyGame.java b/type-object/src/main/java/com/iluwatar/typeobject/CandyGame.java index 85d39c8c7..6e07a88a3 100644 --- a/type-object/src/main/java/com/iluwatar/typeobject/CandyGame.java +++ b/type-object/src/main/java/com/iluwatar/typeobject/CandyGame.java @@ -28,6 +28,8 @@ import com.iluwatar.typeobject.Candy.Type; import java.util.ArrayList; import java.util.List; import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The CandyGame class contains the rules for the continuation of the game and has the game matrix @@ -37,7 +39,6 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @SuppressWarnings("java:S3776") //"Cognitive Complexity of methods should not be too high" public class CandyGame { - Cell[][] cells; CellPool pool; int totalPoints; @@ -85,17 +86,20 @@ public class CandyGame { if (x == 0) { adjacent.add(this.cells[y][1]); } - if (y == cells.length - 1) { + if (y == cells.length - 1 && cells.length > 1) { adjacent.add(this.cells[cells.length - 2][x]); } - if (x == cells.length - 1) { + + if (x == cells.length - 1 && cells.length > 1) { adjacent.add(this.cells[y][cells.length - 2]); } + + if (y > 0 && y < cells.length - 1) { adjacent.add(this.cells[y - 1][x]); adjacent.add(this.cells[y + 1][x]); } - if (x > 0 && x < cells.length - 1) { + if (y >= 0 && y < cells.length && x > 0 && x < cells[y].length - 1) { adjacent.add(this.cells[y][x - 1]); adjacent.add(this.cells[y][x + 1]); }