📍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:
@ -37,10 +37,9 @@ Wikipedia says
|
||||
Let's first introduce the `Tobacco` interface and the concrete brands.
|
||||
|
||||
```java
|
||||
@Slf4j
|
||||
public abstract class Tobacco {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Tobacco.class);
|
||||
|
||||
public void smoke(Wizard wizard) {
|
||||
LOGGER.info("{} smoking {}", wizard.getClass().getSimpleName(),
|
||||
this.getClass().getSimpleName());
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
package com.iluwatar.dependency.injection;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* AdvancedSorceress implements inversion of control. It depends on abstraction that can be injected
|
||||
* through its setter.
|
||||
*/
|
||||
@Setter
|
||||
public class AdvancedSorceress implements Wizard {
|
||||
|
||||
private Tobacco tobacco;
|
||||
|
||||
public void setTobacco(Tobacco tobacco) {
|
||||
this.tobacco = tobacco;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void smoke() {
|
||||
tobacco.smoke(this);
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
package com.iluwatar.dependency.injection;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* AdvancedWizard implements inversion of control. It depends on abstraction that can be injected
|
||||
* through its constructor.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class AdvancedWizard implements Wizard {
|
||||
|
||||
private final Tobacco tobacco;
|
||||
|
||||
public AdvancedWizard(Tobacco tobacco) {
|
||||
this.tobacco = tobacco;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void smoke() {
|
||||
tobacco.smoke(this);
|
||||
|
@ -23,16 +23,14 @@
|
||||
|
||||
package com.iluwatar.dependency.injection;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Tobacco abstraction.
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class Tobacco {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Tobacco.class);
|
||||
|
||||
public void smoke(Wizard wizard) {
|
||||
LOGGER.info("{} smoking {}", wizard.getClass().getSimpleName(),
|
||||
this.getClass().getSimpleName());
|
||||
|
@ -38,17 +38,17 @@ import org.junit.jupiter.api.Test;
|
||||
* @author Stanislav Kapinus
|
||||
*/
|
||||
|
||||
public class AdvancedSorceressTest {
|
||||
class AdvancedSorceressTest {
|
||||
|
||||
private InMemoryAppender appender;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
appender = new InMemoryAppender(Tobacco.class);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
appender.stop();
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class AdvancedSorceressTest {
|
||||
* her through the setter's parameter
|
||||
*/
|
||||
@Test
|
||||
public void testSmokeEveryThing() throws Exception {
|
||||
void testSmokeEveryThing() throws Exception {
|
||||
|
||||
List<Tobacco> tobaccos = List.of(
|
||||
new OldTobyTobacco(),
|
||||
|
@ -37,17 +37,17 @@ import org.junit.jupiter.api.Test;
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class AdvancedWizardTest {
|
||||
class AdvancedWizardTest {
|
||||
|
||||
private InMemoryAppender appender;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
appender = new InMemoryAppender(Tobacco.class);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
appender.stop();
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public class AdvancedWizardTest {
|
||||
* through the constructor parameter
|
||||
*/
|
||||
@Test
|
||||
public void testSmokeEveryThing() throws Exception {
|
||||
void testSmokeEveryThing() throws Exception {
|
||||
|
||||
List<Tobacco> tobaccos = List.of(
|
||||
new OldTobyTobacco(),
|
||||
|
@ -38,17 +38,17 @@ import org.junit.jupiter.api.Test;
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class GuiceWizardTest {
|
||||
class GuiceWizardTest {
|
||||
|
||||
private InMemoryAppender appender;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
appender = new InMemoryAppender(Tobacco.class);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
appender.stop();
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class GuiceWizardTest {
|
||||
* through the constructor parameter
|
||||
*/
|
||||
@Test
|
||||
public void testSmokeEveryThingThroughConstructor() throws Exception {
|
||||
void testSmokeEveryThingThroughConstructor() throws Exception {
|
||||
|
||||
List<Tobacco> tobaccos = List.of(
|
||||
new OldTobyTobacco(),
|
||||
@ -82,7 +82,7 @@ public class GuiceWizardTest {
|
||||
* through the Guice google inject framework
|
||||
*/
|
||||
@Test
|
||||
public void testSmokeEveryThingThroughInjectionFramework() throws Exception {
|
||||
void testSmokeEveryThingThroughInjectionFramework() throws Exception {
|
||||
|
||||
List<Class<? extends Tobacco>> tobaccos = List.of(
|
||||
OldTobyTobacco.class,
|
||||
|
@ -35,17 +35,17 @@ import org.junit.jupiter.api.Test;
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class SimpleWizardTest {
|
||||
class SimpleWizardTest {
|
||||
|
||||
private InMemoryAppender appender;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
appender = new InMemoryAppender(Tobacco.class);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
appender.stop();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class SimpleWizardTest {
|
||||
* OldTobyTobacco}
|
||||
*/
|
||||
@Test
|
||||
public void testSmoke() {
|
||||
void testSmoke() {
|
||||
final var simpleWizard = new SimpleWizard();
|
||||
simpleWizard.smoke();
|
||||
assertEquals("SimpleWizard smoking OldTobyTobacco", appender.getLastMessage());
|
||||
|
Reference in New Issue
Block a user