generic repository is small library for persisting java objects
example using jdbc implementation of generic repository which comes from library
private GenericRepository<Human, Connection> humanRepository = new JdbcRepository<>("human",
humanObject -> {
Map<String, Object> humanData = new LinkedHashMap<>();
humanData.put("age", humanObject.getAge());
humanData.put("name", humanObject.getName());
return humanData;
},
resultSet -> {
return new Human(resultSet.getInt("id"),
resultSet.getInt("age"),
resultSet.getString("name"));
});
private Human selectHumanWithAge(int age, Connection connection){
return humanRepository
.objectFromWhere("age", age)
.executeWith(connection);
}