📍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

@ -39,10 +39,9 @@ Wikipedia says
Let's first introduce the template method class along with its concrete implementations.
```java
@Slf4j
public abstract class StealingMethod {
private static final Logger LOGGER = LoggerFactory.getLogger(StealingMethod.class);
protected abstract String pickTarget();
protected abstract void confuseTarget(String target);
@ -57,10 +56,9 @@ public abstract class StealingMethod {
}
}
@Slf4j
public class SubtleMethod extends StealingMethod {
private static final Logger LOGGER = LoggerFactory.getLogger(SubtleMethod.class);
@Override
protected String pickTarget() {
return "shop keeper";
@ -77,10 +75,9 @@ public class SubtleMethod extends StealingMethod {
}
}
@Slf4j
public class HitAndRunMethod extends StealingMethod {
private static final Logger LOGGER = LoggerFactory.getLogger(HitAndRunMethod.class);
@Override
protected String pickTarget() {
return "old goblin woman";

View File

@ -23,16 +23,14 @@
package com.iluwatar.templatemethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* HitAndRunMethod implementation of {@link StealingMethod}.
*/
@Slf4j
public class HitAndRunMethod extends StealingMethod {
private static final Logger LOGGER = LoggerFactory.getLogger(HitAndRunMethod.class);
@Override
protected String pickTarget() {
return "old goblin woman";

View File

@ -23,16 +23,14 @@
package com.iluwatar.templatemethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* StealingMethod defines skeleton for the algorithm.
*/
@Slf4j
public abstract class StealingMethod {
private static final Logger LOGGER = LoggerFactory.getLogger(StealingMethod.class);
protected abstract String pickTarget();
protected abstract void confuseTarget(String target);

View File

@ -23,16 +23,14 @@
package com.iluwatar.templatemethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* SubtleMethod implementation of {@link StealingMethod}.
*/
@Slf4j
public class SubtleMethod extends StealingMethod {
private static final Logger LOGGER = LoggerFactory.getLogger(SubtleMethod.class);
@Override
protected String pickTarget() {
return "shop keeper";

View File

@ -40,7 +40,7 @@ public class HalflingThiefTest {
* Verify if the thief uses the provided stealing method
*/
@Test
public void testSteal() {
void testSteal() {
final var method = mock(StealingMethod.class);
final var thief = new HalflingThief(method);
@ -54,7 +54,7 @@ public class HalflingThiefTest {
* Verify if the thief uses the provided stealing method, and the new method after changing it
*/
@Test
public void testChangeMethod() {
void testChangeMethod() {
final var initialMethod = mock(StealingMethod.class);
final var thief = new HalflingThief(initialMethod);

View File

@ -104,7 +104,7 @@ public abstract class StealingMethodTest<M extends StealingMethod> {
* Verify if the thief picks the correct target
*/
@Test
public void testPickTarget() {
void testPickTarget() {
assertEquals(expectedTarget, this.method.pickTarget());
}
@ -112,7 +112,7 @@ public abstract class StealingMethodTest<M extends StealingMethod> {
* Verify if the target confusing step goes as planned
*/
@Test
public void testConfuseTarget() {
void testConfuseTarget() {
assertEquals(0, appender.getLogSize());
this.method.confuseTarget(this.expectedTarget);
@ -124,7 +124,7 @@ public abstract class StealingMethodTest<M extends StealingMethod> {
* Verify if the stealing step goes as planned
*/
@Test
public void testStealTheItem() {
void testStealTheItem() {
assertEquals(0, appender.getLogSize());
this.method.stealTheItem(this.expectedTarget);
@ -136,7 +136,7 @@ public abstract class StealingMethodTest<M extends StealingMethod> {
* Verify if the complete steal process goes as planned
*/
@Test
public void testSteal() {
void testSteal() {
this.method.steal();
assertTrue(appender.logContains(this.expectedTargetResult));