📍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

@ -83,8 +83,8 @@ public interface IUnitOfWork<T> {
void commit();
}
@Slf4j
public class StudentRepository implements IUnitOfWork<Student> {
private static final Logger LOGGER = LoggerFactory.getLogger(StudentRepository.class);
private final Map<String, List<Student>> context;
private final StudentDatabase studentDatabase;

View File

@ -23,36 +23,18 @@
package com.iluwatar.unitofwork;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* {@link Student} is an entity.
*/
@Getter
@RequiredArgsConstructor
public class Student {
private final Integer id;
private final String name;
private final String address;
/**
* Constructor.
*
* @param id student unique id
* @param name name of student
* @param address address of student
*/
public Student(Integer id, String name, String address) {
this.id = id;
this.name = name;
this.address = address;
}
public String getName() {
return name;
}
public Integer getId() {
return id;
}
public String getAddress() {
return address;
}
}

View File

@ -26,29 +26,19 @@ package com.iluwatar.unitofwork;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* {@link StudentRepository} Student database repository. supports unit of work for student data.
*/
@Slf4j
@RequiredArgsConstructor
public class StudentRepository implements IUnitOfWork<Student> {
private static final Logger LOGGER = LoggerFactory.getLogger(StudentRepository.class);
private final Map<String, List<Student>> context;
private final StudentDatabase studentDatabase;
/**
* Constructor.
*
* @param context set of operations to be perform during commit.
* @param studentDatabase Database for student records.
*/
public StudentRepository(Map<String, List<Student>> context, StudentDatabase studentDatabase) {
this.context = context;
this.studentDatabase = studentDatabase;
}
@Override
public void registerNew(Student student) {
LOGGER.info("Registering {} for insert in context.", student.getName());

View File

@ -23,18 +23,15 @@
package com.iluwatar.unitofwork;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
public enum UnitActions {
INSERT("INSERT"),
DELETE("DELETE"),
MODIFY("MODIFY");
private final String actionValue;
UnitActions(String actionValue) {
this.actionValue = actionValue;
}
public String getActionValue() {
return actionValue;
}
}