mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 14:59:25 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -43,11 +43,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*
|
||||
* <p>In this example, we create a new Lockable object with the SwordOfAragorn implementation of it.
|
||||
* Afterward we create 6 Creatures with the Elf, Orc and Human implementations and assign them each
|
||||
* to a Fiend object and the Sword is the target object. Because there is only one Sword, and it uses
|
||||
* the Lockable Object pattern, only one creature can hold the sword at a given time. When the sword
|
||||
* is locked, any other alive Fiends will try to lock, which will result in a race to lock the
|
||||
* to a Fiend object and the Sword is the target object. Because there is only one Sword, and it
|
||||
* uses the Lockable Object pattern, only one creature can hold the sword at a given time. When the
|
||||
* sword is locked, any other alive Fiends will try to lock, which will result in a race to lock the
|
||||
* sword.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class App implements Runnable {
|
||||
|
||||
@@ -26,16 +26,12 @@ package com.iluwatar.lockableobject;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* An exception regarding the locking process of a Lockable object.
|
||||
*/
|
||||
/** An exception regarding the locking process of a Lockable object. */
|
||||
public class LockingException extends RuntimeException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 8556381044865867037L;
|
||||
@Serial private static final long serialVersionUID = 8556381044865867037L;
|
||||
|
||||
public LockingException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* An implementation of a Lockable object. This is the Sword of Aragorn and every creature wants
|
||||
* to possess it!
|
||||
* An implementation of a Lockable object. This is the Sword of Aragorn and every creature wants to
|
||||
* possess it!
|
||||
*/
|
||||
@Slf4j
|
||||
public class SwordOfAragorn implements Lockable {
|
||||
|
||||
@@ -109,5 +109,4 @@ public abstract class Creature {
|
||||
public synchronized boolean isAlive() {
|
||||
return getHealth() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ public enum CreatureStats {
|
||||
HUMAN_HEALTH(60),
|
||||
HUMAN_DAMAGE(60);
|
||||
|
||||
@Getter
|
||||
final int value;
|
||||
@Getter final int value;
|
||||
|
||||
CreatureStats(int value) {
|
||||
this.value = value;
|
||||
|
||||
Reference in New Issue
Block a user