Java 11 migrate c-d (remaining) (#1111)

* Moves converter pattern to Java 11

* Moves cqrs pattern to Java 11

* Moves dao pattern to Java 11

* Moves data-bus pattern to Java 11

* Moves data-locality pattern to Java 11

* Moves data-mapper pattern to Java 11

* Moves data-transfer-object pattern to Java 11

* Moves decorator pattern to Java 11

* Moves delegation pattern to Java 11

* Moves dependency-injection to Java 11

* Moves dirty-flag to Java 11

* Moves double-buffer to Java 11

* Moves double-checked-locking to Java 11

* Moves double-dispatch to Java 11

* Corrects with changes thats breaking test cases
This commit is contained in:
Anurag Agarwal
2019-12-15 00:02:45 +05:30
committed by Ilkka Seppälä
parent 5681684157
commit ea57934db6
75 changed files with 576 additions and 713 deletions

View File

@ -46,7 +46,7 @@ public class Application {
*/
public static void main(String[] args) {
LOGGER.info("Start Game Application using Data-Locality pattern");
GameEntity gameEntity = new GameEntity(NUM_ENTITIES);
var gameEntity = new GameEntity(NUM_ENTITIES);
gameEntity.start();
gameEntity.update();
}

View File

@ -25,6 +25,7 @@ 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;
@ -50,9 +51,7 @@ public class AiComponentManager {
*/
public void start() {
LOGGER.info("Start AI Game Component");
for (int i = 0; i < numEntities; i++) {
AI_COMPONENTS[i] = new AiComponent();
}
IntStream.range(0, numEntities).forEach(i -> AI_COMPONENTS[i] = new AiComponent());
}
/**
@ -60,10 +59,8 @@ public class AiComponentManager {
*/
public void update() {
LOGGER.info("Update AI Game Component");
for (int i = 0; i < numEntities; i++) {
if (AI_COMPONENTS.length > i && AI_COMPONENTS[i] != null) {
AI_COMPONENTS[i].update();
}
}
IntStream.range(0, numEntities)
.filter(i -> AI_COMPONENTS.length > i && AI_COMPONENTS[i] != null)
.forEach(i -> AI_COMPONENTS[i].update());
}
}

View File

@ -25,6 +25,7 @@ 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;
@ -50,9 +51,7 @@ public class PhysicsComponentManager {
*/
public void start() {
LOGGER.info("Start Physics Game Component ");
for (int i = 0; i < numEntities; i++) {
PHYSICS_COMPONENTS[i] = new PhysicsComponent();
}
IntStream.range(0, numEntities).forEach(i -> PHYSICS_COMPONENTS[i] = new PhysicsComponent());
}
@ -62,10 +61,8 @@ public class PhysicsComponentManager {
public void update() {
LOGGER.info("Update Physics Game Component ");
// Process physics.
for (int i = 0; i < numEntities; i++) {
if (PHYSICS_COMPONENTS.length > i && PHYSICS_COMPONENTS[i] != null) {
PHYSICS_COMPONENTS[i].update();
}
}
IntStream.range(0, numEntities)
.filter(i -> PHYSICS_COMPONENTS.length > i && PHYSICS_COMPONENTS[i] != null)
.forEach(i -> PHYSICS_COMPONENTS[i].update());
}
}

View File

@ -25,6 +25,7 @@ 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;
@ -50,9 +51,7 @@ public class RenderComponentManager {
*/
public void start() {
LOGGER.info("Start Render Game Component ");
for (int i = 0; i < numEntities; i++) {
RENDER_COMPONENTS[i] = new RenderComponent();
}
IntStream.range(0, numEntities).forEach(i -> RENDER_COMPONENTS[i] = new RenderComponent());
}
@ -62,10 +61,8 @@ public class RenderComponentManager {
public void render() {
LOGGER.info("Update Render Game Component ");
// Process Render.
for (int i = 0; i < numEntities; i++) {
if (RENDER_COMPONENTS.length > i && RENDER_COMPONENTS[i] != null) {
RENDER_COMPONENTS[i].render();
}
}
IntStream.range(0, numEntities)
.filter(i -> RENDER_COMPONENTS.length > i && RENDER_COMPONENTS[i] != null)
.forEach(i -> RENDER_COMPONENTS[i].render());
}
}