Various cleanups according to code check

This commit is contained in:
2019-03-11 22:11:24 +01:00
parent 0d83ea75b2
commit 07a454e227
10 changed files with 13 additions and 13 deletions

View File

@@ -34,6 +34,6 @@ public enum ResponseReason {
} }
public ResponseEntity toResponseEntity() { public ResponseEntity toResponseEntity() {
return new ResponseEntity(this.name(), this.httpStatus); return new ResponseEntity<>(this.name(), this.httpStatus);
} }
} }

View File

@@ -41,7 +41,7 @@ public class FinancerConfig {
* via {@link FinancerConfig#getCountryCode}. * via {@link FinancerConfig#getCountryCode}.
*/ */
public HolidayCalendar getHolidayCalendar() { public HolidayCalendar getHolidayCalendar() {
final Optional<HolidayCalendar> optionalHoliday = Arrays.asList(HolidayCalendar.values()).stream() final Optional<HolidayCalendar> optionalHoliday = Arrays.stream(HolidayCalendar.values())
.filter((hc) -> hc.getId().equals(this.countryCode)) .filter((hc) -> hc.getId().equals(this.countryCode))
.findFirst(); .findFirst();

View File

@@ -4,5 +4,5 @@ public enum AccountStatus {
/** Indicates that the account is open for bookings */ /** Indicates that the account is open for bookings */
OPEN, OPEN,
/** Indicates that the account is closed and bookings to it are forbidden */ /** Indicates that the account is closed and bookings to it are forbidden */
CLOSED; CLOSED
} }

View File

@@ -28,6 +28,6 @@ public enum AccountType {
* @return whether the given type represents a valid account type * @return whether the given type represents a valid account type
*/ */
public static boolean isValidType(String type) { public static boolean isValidType(String type) {
return Arrays.asList(AccountType.values()).stream().anyMatch((accountType) -> accountType.name().equals(type)); return Arrays.stream(AccountType.values()).anyMatch((accountType) -> accountType.name().equals(type));
} }
} }

View File

@@ -60,6 +60,6 @@ public enum HolidayWeekendType {
* @return whether the given type represents a valid holiday weekend type * @return whether the given type represents a valid holiday weekend type
*/ */
public static boolean isValidType(String type) { public static boolean isValidType(String type) {
return Arrays.asList(HolidayWeekendType.values()).stream().anyMatch((holidayWeekendType) -> holidayWeekendType.name().equals(type)); return Arrays.stream(HolidayWeekendType.values()).anyMatch((holidayWeekendType) -> holidayWeekendType.name().equals(type));
} }
} }

View File

@@ -25,6 +25,6 @@ public enum IntervalType {
* @return whether the given type represents a valid interval type * @return whether the given type represents a valid interval type
*/ */
public static boolean isValidType(String type) { public static boolean isValidType(String type) {
return Arrays.asList(IntervalType.values()).stream().anyMatch((intervalType) -> intervalType.name().equals(type)); return Arrays.stream(IntervalType.values()).anyMatch((intervalType) -> intervalType.name().equals(type));
} }
} }

View File

@@ -44,14 +44,14 @@ public class AccountService {
* @return all possible account types as specified by the {@link AccountType} enumeration, never <code>null</code> * @return all possible account types as specified by the {@link AccountType} enumeration, never <code>null</code>
*/ */
public Iterable<String> getAccountTypes() { public Iterable<String> getAccountTypes() {
return Arrays.asList(AccountType.values()).stream().map(AccountType::name).collect(Collectors.toList()); return Arrays.stream(AccountType.values()).map(AccountType::name).collect(Collectors.toList());
} }
/** /**
* @return all possible account status as specified by the {@link AccountStatus} enumeration, never <code>null</code> * @return all possible account status as specified by the {@link AccountStatus} enumeration, never <code>null</code>
*/ */
public Iterable<String> getAccountStatus() { public Iterable<String> getAccountStatus() {
return Arrays.asList(AccountStatus.values()).stream().map(AccountStatus::name).collect(Collectors.toList()); return Arrays.stream(AccountStatus.values()).map(AccountStatus::name).collect(Collectors.toList());
} }
/** /**
@@ -93,7 +93,7 @@ public class AccountService {
// If we create an account it's implicitly open // If we create an account it's implicitly open
account.setStatus(AccountStatus.OPEN); account.setStatus(AccountStatus.OPEN);
// and has a current balance of 0 // and has a current balance of 0
account.setCurrentBalance(Long.valueOf(0l)); account.setCurrentBalance(Long.valueOf(0L));
try { try {
this.accountRepository.save(account); this.accountRepository.save(account);

View File

@@ -330,7 +330,7 @@ public class RecurringTransactionService {
response = ResponseReason.INVALID_BOOKING_ACCOUNTS; response = ResponseReason.INVALID_BOOKING_ACCOUNTS;
} else if (amount == null) { } else if (amount == null) {
response = ResponseReason.MISSING_AMOUNT; response = ResponseReason.MISSING_AMOUNT;
} else if (amount == 0l) { } else if (amount == 0L) {
response = ResponseReason.AMOUNT_ZERO; response = ResponseReason.AMOUNT_ZERO;
} else if (holidayWeekendType == null) { } else if (holidayWeekendType == null) {
response = ResponseReason.MISSING_HOLIDAY_WEEKEND_TYPE; response = ResponseReason.MISSING_HOLIDAY_WEEKEND_TYPE;
@@ -382,7 +382,7 @@ public class RecurringTransactionService {
return this.transactionService.createTransaction(recurringTransaction.getFromAccount().getKey(), return this.transactionService.createTransaction(recurringTransaction.getFromAccount().getKey(),
recurringTransaction.getToAccount().getKey(), recurringTransaction.getToAccount().getKey(),
amount.orElseGet(() -> recurringTransaction.getAmount()), amount.orElseGet(recurringTransaction::getAmount),
LocalDate.now().format(DateTimeFormatter.ofPattern(this.financerConfig.getDateFormat())), LocalDate.now().format(DateTimeFormatter.ofPattern(this.financerConfig.getDateFormat())),
recurringTransaction.getDescription(), recurringTransaction.getDescription(),
recurringTransaction); recurringTransaction);

View File

@@ -154,7 +154,7 @@ public class TransactionService {
response = ResponseReason.INVALID_BOOKING_ACCOUNTS; response = ResponseReason.INVALID_BOOKING_ACCOUNTS;
} else if (amount == null) { } else if (amount == null) {
response = ResponseReason.MISSING_AMOUNT; response = ResponseReason.MISSING_AMOUNT;
} else if (amount == 0l) { } else if (amount == 0L) {
response = ResponseReason.AMOUNT_ZERO; response = ResponseReason.AMOUNT_ZERO;
} else if (date == null) { } else if (date == null) {
response = ResponseReason.MISSING_DATE; response = ResponseReason.MISSING_DATE;

View File

@@ -52,7 +52,7 @@ public class SendRecurringTransactionReminderTask {
.append(System.lineSeparator()) .append(System.lineSeparator())
.append(System.lineSeparator()); .append(System.lineSeparator());
IterableUtils.toList(recurringTransactions).stream().forEach((rt) -> { IterableUtils.toList(recurringTransactions).forEach((rt) -> {
reminderBuilder.append(rt.getId()) reminderBuilder.append(rt.getId())
.append("|") .append("|")
.append(rt.getDescription()) .append(rt.getDescription())