mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-15 18:23:54 +00:00
* refactoring #1012: Format specifiers should be used instead of string concatenation. * refactoring #1012: Format specifiers should be used instead of string concatenation. * refactoring #1012: Remove isInfoEnabled check
This commit is contained in:
@@ -477,8 +477,8 @@ public class Commander {
|
|||||||
&& System.currentTimeMillis() - o.createdTime < messageTime) {
|
&& System.currentTimeMillis() - o.createdTime < messageTime) {
|
||||||
var qt = new QueueTask(order, TaskType.MESSAGING, 1);
|
var qt = new QueueTask(order, TaskType.MESSAGING, 1);
|
||||||
updateQueue(qt);
|
updateQueue(qt);
|
||||||
LOG.warn("Order " + order.id + ": Error in sending Payment Error message, "
|
LOG.warn("Order {}: Error in sending Payment Error message, trying to queue task and add to employee handle..",
|
||||||
+ "trying to queue task and add to employee handle..");
|
order.id);
|
||||||
employeeHandleIssue(o);
|
employeeHandleIssue(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class App {
|
|||||||
final var logger = LoggerFactory.getLogger(App.class);
|
final var logger = LoggerFactory.getLogger(App.class);
|
||||||
|
|
||||||
var name = unit.getName();
|
var name = unit.getName();
|
||||||
Function<String, Runnable> func = (e) -> () -> logger.info(name + " without " + e);
|
Function<String, Runnable> func = e -> () -> logger.info("{} without {}", name, e);
|
||||||
|
|
||||||
var extension = "SoldierExtension";
|
var extension = "SoldierExtension";
|
||||||
Optional.ofNullable(unit.getUnitExtension(extension))
|
Optional.ofNullable(unit.getUnitExtension(extension))
|
||||||
|
|||||||
@@ -39,12 +39,10 @@ public abstract class GameLoop {
|
|||||||
|
|
||||||
protected final GameController controller;
|
protected final GameController controller;
|
||||||
|
|
||||||
private Thread gameThread;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize game status to be stopped.
|
* Initialize game status to be stopped.
|
||||||
*/
|
*/
|
||||||
public GameLoop() {
|
protected GameLoop() {
|
||||||
controller = new GameController();
|
controller = new GameController();
|
||||||
status = GameStatus.STOPPED;
|
status = GameStatus.STOPPED;
|
||||||
}
|
}
|
||||||
@@ -54,7 +52,7 @@ public abstract class GameLoop {
|
|||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
status = GameStatus.RUNNING;
|
status = GameStatus.RUNNING;
|
||||||
gameThread = new Thread(this::processGameLoop);
|
Thread gameThread = new Thread(this::processGameLoop);
|
||||||
gameThread.start();
|
gameThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +83,8 @@ public abstract class GameLoop {
|
|||||||
Thread.sleep(lag);
|
Thread.sleep(lag);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
|
/* Clean up whatever needs to be handled before interrupting */
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ public abstract class GameLoop {
|
|||||||
*/
|
*/
|
||||||
protected void render() {
|
protected void render() {
|
||||||
var position = controller.getBulletPosition();
|
var position = controller.getBulletPosition();
|
||||||
logger.info("Current bullet position: " + position);
|
logger.info("Current bullet position: {}", position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -42,6 +42,6 @@ public class InvalidUser implements ReceiptViewModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
LOGGER.info("Invalid user: " + userName);
|
LOGGER.info(String.format("Invalid user: %s", userName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,6 @@ public class MaintenanceLock {
|
|||||||
|
|
||||||
public void setLock(boolean lock) {
|
public void setLock(boolean lock) {
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
LOGGER.info("Maintenance lock is set to: ", lock);
|
LOGGER.info("Maintenance lock is set to: {}", lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ public class OutOfStock implements ReceiptViewModel {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(OutOfStock.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(OutOfStock.class);
|
||||||
|
|
||||||
private String userName;
|
private final String userName;
|
||||||
private String itemName;
|
private final String itemName;
|
||||||
|
|
||||||
public OutOfStock(String userName, String itemName) {
|
public OutOfStock(String userName, String itemName) {
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
@@ -44,6 +44,6 @@ public class OutOfStock implements ReceiptViewModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
LOGGER.info("Out of stock: " + itemName + " for user = " + userName + " to buy");
|
LOGGER.info(String.format("Out of stock: %s for user = %s to buy", itemName, userName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class ReceiptDto implements ReceiptViewModel {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ReceiptDto.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ReceiptDto.class);
|
||||||
|
|
||||||
private Double price;
|
private final Double price;
|
||||||
|
|
||||||
public ReceiptDto(Double price) {
|
public ReceiptDto(Double price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
@@ -46,6 +46,6 @@ public class ReceiptDto implements ReceiptViewModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
LOGGER.info("Receipt: " + price + " paid");
|
LOGGER.info(String.format("Receipt: %s paid", price));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public abstract class Superpower {
|
|||||||
* @param z Z coordinate.
|
* @param z Z coordinate.
|
||||||
*/
|
*/
|
||||||
protected void move(double x, double y, double z) {
|
protected void move(double x, double y, double z) {
|
||||||
logger.info("Move to ( " + x + ", " + y + ", " + z + " )");
|
logger.info("Move to ( {}, {}, {} )", x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +56,7 @@ public abstract class Superpower {
|
|||||||
* @param volume Value of volume.
|
* @param volume Value of volume.
|
||||||
*/
|
*/
|
||||||
protected void playSound(String soundName, int volume) {
|
protected void playSound(String soundName, int volume) {
|
||||||
logger.info("Play " + soundName + " with volume " + volume);
|
logger.info("Play {} with volume {}", soundName, volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,6 +65,6 @@ public abstract class Superpower {
|
|||||||
* @param count Count of particles to be spawned.
|
* @param count Count of particles to be spawned.
|
||||||
*/
|
*/
|
||||||
protected void spawnParticles(String particleType, int count) {
|
protected void spawnParticles(String particleType, int count) {
|
||||||
logger.info("Spawn " + count + " particle with type " + particleType);
|
logger.info("Spawn {} particle with type {}", count, particleType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,6 @@ public class Statue extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void shootLightning() {
|
private void shootLightning() {
|
||||||
logger.info("Statue " + id + " shoots lightning!");
|
logger.info("Statue {} shoots lightning!", id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user