📍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

@ -26,8 +26,7 @@ package com.iluwatar.roleobject;
import static com.iluwatar.roleobject.Role.Borrower;
import static com.iluwatar.roleobject.Role.Investor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* The Role Object pattern suggests to model context-specific views of an object as separate role
@ -56,10 +55,9 @@ import org.slf4j.LoggerFactory;
* to return a reference to the corresponding object. The loan application may now use this
* reference to call Borrower-specific operations.
*/
@Slf4j
public class ApplicationRoleObject {
private static final Logger logger = LoggerFactory.getLogger(Role.class);
/**
* Main entry point.
*
@ -68,12 +66,12 @@ public class ApplicationRoleObject {
public static void main(String[] args) {
var customer = Customer.newCustomer(Borrower, Investor);
logger.info(" the new customer created : {}", customer);
LOGGER.info(" the new customer created : {}", customer);
var hasBorrowerRole = customer.hasRole(Borrower);
logger.info(" customer has a borrowed role - {}", hasBorrowerRole);
LOGGER.info(" customer has a borrowed role - {}", hasBorrowerRole);
var hasInvestorRole = customer.hasRole(Investor);
logger.info(" customer has an investor role - {}", hasInvestorRole);
LOGGER.info(" customer has an investor role - {}", hasInvestorRole);
customer.getRole(Investor, InvestorRole.class)
.ifPresent(inv -> {
@ -85,10 +83,10 @@ public class ApplicationRoleObject {
customer.getRole(Investor, InvestorRole.class)
.map(InvestorRole::invest)
.ifPresent(logger::info);
.ifPresent(LOGGER::info);
customer.getRole(Borrower, BorrowerRole.class)
.map(BorrowerRole::borrow)
.ifPresent(logger::info);
.ifPresent(LOGGER::info);
}
}

View File

@ -74,7 +74,6 @@ class CustomerCoreTest {
assertFalse(invRole.isPresent());
}
@Test
void toStringTest() {
var core = new CustomerCore();
@ -87,8 +86,6 @@ class CustomerCoreTest {
core = new CustomerCore();
assertEquals("Customer{roles=[]}", core.toString());
}
}