📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@ -24,8 +24,7 @@
|
||||
package com.iluwatar.data.locality;
|
||||
|
||||
import com.iluwatar.data.locality.game.GameEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Use the Data Locality pattern is when you have a performance problem. Take advantage of that to
|
||||
@ -35,10 +34,9 @@ import org.slf4j.LoggerFactory;
|
||||
* <p>Example: Game loop that processes a bunch of game entities. Those entities are decomposed
|
||||
* into different domains — AI, physics, and rendering — using the Component pattern.
|
||||
*/
|
||||
@Slf4j
|
||||
public class Application {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
|
||||
|
||||
private static final int NUM_ENTITIES = 5;
|
||||
|
||||
/**
|
||||
|
@ -26,8 +26,7 @@ package com.iluwatar.data.locality.game;
|
||||
import com.iluwatar.data.locality.game.component.manager.AiComponentManager;
|
||||
import com.iluwatar.data.locality.game.component.manager.PhysicsComponentManager;
|
||||
import com.iluwatar.data.locality.game.component.manager.RenderComponentManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* The game Entity maintains a big array of pointers . Each spin of the game loop, we need to run
|
||||
@ -39,8 +38,8 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
* <p>Render them using their render components.
|
||||
*/
|
||||
@Slf4j
|
||||
public class GameEntity {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GameEntity.class);
|
||||
|
||||
private final AiComponentManager aiComponentManager;
|
||||
private final PhysicsComponentManager physicsComponentManager;
|
||||
|
@ -23,16 +23,14 @@
|
||||
|
||||
package com.iluwatar.data.locality.game.component;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Implementation of AI component for Game.
|
||||
*/
|
||||
@Slf4j
|
||||
public class AiComponent implements Component {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AiComponent.class);
|
||||
|
||||
/**
|
||||
* Update ai component.
|
||||
*/
|
||||
|
@ -23,16 +23,14 @@
|
||||
|
||||
package com.iluwatar.data.locality.game.component;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Implementation of Physics Component of Game.
|
||||
*/
|
||||
@Slf4j
|
||||
public class PhysicsComponent implements Component {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PhysicsComponent.class);
|
||||
|
||||
/**
|
||||
* update physics component of game.
|
||||
*/
|
||||
|
@ -23,16 +23,14 @@
|
||||
|
||||
package com.iluwatar.data.locality.game.component;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Implementation of Render Component of Game.
|
||||
*/
|
||||
@Slf4j
|
||||
public class RenderComponent implements Component {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RenderComponent.class);
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
// do nothing
|
||||
|
@ -26,16 +26,14 @@ package com.iluwatar.data.locality.game.component.manager;
|
||||
import com.iluwatar.data.locality.game.component.AiComponent;
|
||||
import com.iluwatar.data.locality.game.component.Component;
|
||||
import java.util.stream.IntStream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* AI component manager for Game.
|
||||
*/
|
||||
@Slf4j
|
||||
public class AiComponentManager {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AiComponentManager.class);
|
||||
|
||||
private static final int MAX_ENTITIES = 10000;
|
||||
|
||||
private final int numEntities;
|
||||
|
@ -26,16 +26,14 @@ package com.iluwatar.data.locality.game.component.manager;
|
||||
import com.iluwatar.data.locality.game.component.Component;
|
||||
import com.iluwatar.data.locality.game.component.PhysicsComponent;
|
||||
import java.util.stream.IntStream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Physics component Manager for Game.
|
||||
*/
|
||||
@Slf4j
|
||||
public class PhysicsComponentManager {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PhysicsComponentManager.class);
|
||||
|
||||
private static final int MAX_ENTITIES = 10000;
|
||||
|
||||
private final int numEntities;
|
||||
|
@ -26,16 +26,14 @@ package com.iluwatar.data.locality.game.component.manager;
|
||||
import com.iluwatar.data.locality.game.component.Component;
|
||||
import com.iluwatar.data.locality.game.component.RenderComponent;
|
||||
import java.util.stream.IntStream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Render component manager for Game.
|
||||
*/
|
||||
@Slf4j
|
||||
public class RenderComponentManager {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RenderComponentManager.class);
|
||||
|
||||
private static final int MAX_ENTITIES = 10000;
|
||||
|
||||
private final int numEntities;
|
||||
|
@ -42,6 +42,6 @@ class ApplicationTest {
|
||||
|
||||
@Test
|
||||
void shouldExecuteGameApplicationWithoutException() {
|
||||
assertDoesNotThrow(() -> Application.main(new String[] {}));
|
||||
assertDoesNotThrow(() -> Application.main(new String[]{}));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user