📍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:
va1m
2021-03-13 13:19:21 +01:00
committed by GitHub
parent 0e26a6adb5
commit 5cf2fe009b
681 changed files with 2472 additions and 4966 deletions
@@ -24,8 +24,7 @@
package com.iluwatar.bytecode;
import com.iluwatar.bytecode.util.InstructionConverterUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* The intention of Bytecode pattern is to give behavior the flexibility of data by encoding it as
@@ -40,8 +39,8 @@ import org.slf4j.LoggerFactory;
* ensure the behavior being defined cant break the game, you need to sandbox it from the rest of
* the codebase.
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Main app method.
@@ -23,9 +23,14 @@
package com.iluwatar.bytecode;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* Representation of instructions understandable by virtual machine.
*/
@AllArgsConstructor
@Getter
public enum Instruction {
LITERAL(1),
@@ -40,15 +45,7 @@ public enum Instruction {
ADD(10),
DIVIDE(11);
private final int value;
Instruction(int value) {
this.value = value;
}
public int getIntValue() {
return value;
}
private final int intValue;
/**
* Converts integer value to Instruction.
@@ -24,10 +24,12 @@
package com.iluwatar.bytecode;
import java.util.Stack;
import lombok.Getter;
/**
* Implementation of virtual machine.
*/
@Getter
public class VirtualMachine {
private final Stack<Integer> stack = new Stack<>();
@@ -108,10 +110,6 @@ public class VirtualMachine {
}
}
public Stack<Integer> getStack() {
return stack;
}
public void setHealth(int wizard, int amount) {
wizards[wizard].setHealth(amount);
}
@@ -135,8 +133,4 @@ public class VirtualMachine {
public int getAgility(int wizard) {
return wizards[wizard].getAgility();
}
public Wizard[] getWizards() {
return wizards;
}
}
@@ -23,15 +23,18 @@
package com.iluwatar.bytecode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
/**
* This class represent game objects which properties can be changed by instructions interpreted by
* virtual machine.
*/
@Setter
@Getter
@Slf4j
public class Wizard {
private static final Logger LOGGER = LoggerFactory.getLogger(Wizard.class);
private int health;
@@ -41,30 +44,6 @@ public class Wizard {
private int numberOfPlayedSounds;
private int numberOfSpawnedParticles;
public int getHealth() {
return health;
}
public void setHealth(int health) {
this.health = health;
}
public int getAgility() {
return agility;
}
public void setAgility(int agility) {
this.agility = agility;
}
public int getWisdom() {
return wisdom;
}
public void setWisdom(int wisdom) {
this.wisdom = wisdom;
}
public void playSound() {
LOGGER.info("Playing sound");
numberOfPlayedSounds++;
@@ -75,11 +54,4 @@ public class Wizard {
numberOfSpawnedParticles++;
}
public int getNumberOfPlayedSounds() {
return numberOfPlayedSounds;
}
public int getNumberOfSpawnedParticles() {
return numberOfSpawnedParticles;
}
}