Refactoring
This commit is contained in:
parent
3f19bd2737
commit
8ea3c0b738
@ -10,7 +10,7 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>patterns</artifactId>
|
<artifactId>persitence</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -4,15 +4,15 @@ import fr.gasser.daoexample.model.Entity;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class Dao<T extends Entity> {
|
public interface Dao<T extends Entity> {
|
||||||
|
|
||||||
public abstract boolean create(T obj);
|
boolean create(T obj);
|
||||||
|
|
||||||
public abstract T find(int id);
|
T find(int id);
|
||||||
|
|
||||||
public abstract List<T> findAll();
|
List<T> findAll();
|
||||||
|
|
||||||
public abstract boolean update(T obj);
|
boolean update(T obj);
|
||||||
|
|
||||||
public abstract boolean delete(T obj);
|
boolean delete(T obj);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DisciplineDao extends Dao<Discipline> {
|
public class DisciplineDao implements Dao<Discipline> {
|
||||||
|
|
||||||
// Emulate discipline table
|
// Emulate discipline table
|
||||||
private final static List<Discipline> DISCIPLINES = new ArrayList<>(Arrays.asList(
|
private final static List<Discipline> DISCIPLINES = new ArrayList<>(Arrays.asList(
|
||||||
|
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class StudentDao extends Dao<Student> {
|
public class StudentDao implements Dao<Student> {
|
||||||
|
|
||||||
// Emulate student table
|
// Emulate student table
|
||||||
private final static List<Student> students = new ArrayList<>(Arrays.asList(
|
private final static List<Student> students = new ArrayList<>(Arrays.asList(
|
||||||
|
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TeacherDao extends Dao<Teacher> {
|
public class TeacherDao implements Dao<Teacher> {
|
||||||
|
|
||||||
// Emulate teacher table
|
// Emulate teacher table
|
||||||
private final static List<Teacher> teachers = new ArrayList<>(Arrays.asList(
|
private final static List<Teacher> teachers = new ArrayList<>(Arrays.asList(
|
||||||
|
@ -15,7 +15,7 @@ import java.sql.Statement;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class StudentSQLiteDao extends Dao<Student> {
|
public class StudentSQLiteDao implements Dao<Student> {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(StudentSQLiteDao.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(StudentSQLiteDao.class);
|
||||||
private final ConnectionWrapper wrapper;
|
private final ConnectionWrapper wrapper;
|
||||||
|
Loading…
Reference in New Issue
Block a user