📍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

@ -23,22 +23,20 @@
package com.iluwatar.factory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* Factory is an object for creating other objects, it providing Providing a static method to
* create and return objects of varying classes, in order to hide the implementation logic
* and makes client code focus on usage rather then objects initialization and management.
*
*
* <p>In this example the CarFactory is the factory class and it provides a static method to
* create different cars.
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program main entry point.
*/

View File

@ -27,7 +27,7 @@ package com.iluwatar.factory;
* Car interface.
*/
public interface Car {
String getDescription();
}

View File

@ -24,22 +24,19 @@
package com.iluwatar.factory;
import java.util.function.Supplier;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* Enumeration for different types of cars.
*/
@RequiredArgsConstructor
@Getter
public enum CarType {
/**
* Enumeration for different types of cars.
*/
FORD(Ford::new),
FORD(Ford::new),
FERRARI(Ferrari::new);
private final Supplier<Car> constructor;
CarType(Supplier<Car> constructor) {
this.constructor = constructor;
}
public Supplier<Car> getConstructor() {
return this.constructor;
}
private final Supplier<Car> constructor;
}

View File

@ -27,7 +27,7 @@ package com.iluwatar.factory;
* Factory of cars.
*/
public class CarsFactory {
/**
* Factory method takes as parameter a car type and initiate the appropriate class.
*/

View File

@ -27,7 +27,7 @@ package com.iluwatar.factory;
* Ferrari implementation.
*/
public class Ferrari implements Car {
static final String DESCRIPTION = "This is Ferrari.";
@Override

View File

@ -29,9 +29,9 @@ import org.junit.jupiter.api.Test;
class AppTest {
@Test
void shouldExecuteWithoutExceptions() {
assertDoesNotThrow(() -> App.main(new String[]{}));
}
@Test
void shouldExecuteWithoutExceptions() {
assertDoesNotThrow(() -> App.main(new String[]{}));
}
}

View File

@ -29,10 +29,10 @@ import org.junit.jupiter.api.Test;
class CarsFactoryTest {
@Test
void shouldReturnFerrariInstance() {
final var ferrari = CarsFactory.getCar(CarType.FERRARI);
assertTrue(ferrari instanceof Ferrari);
}
@Test
void shouldReturnFerrariInstance() {
final var ferrari = CarsFactory.getCar(CarType.FERRARI);
assertTrue(ferrari instanceof Ferrari);
}
}