📍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

View File

@ -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());

View File

@ -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);

View File

@ -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);

View File

@ -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());

View File

@ -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(),

View File

@ -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(),

View File

@ -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,

View File

@ -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());