refactor: renamed everything

This commit is contained in:
David Guler
2022-11-14 13:47:22 +01:00
parent a5e1acc7c3
commit 4f80a0a3e0
24 changed files with 193 additions and 211 deletions
@@ -6,7 +6,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Optional;
public interface GardenPlan {
public interface CropList {
/**
* Yields a list of all {@link Crop}s in the database.
*
@@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
public class JsonGardenPlan implements GardenPlan {
public class JsonCropList implements CropList {
private final URL dataSource;
private IdProvider idProvider;
@@ -42,7 +42,7 @@ public class JsonGardenPlan implements GardenPlan {
/**
* Default constructor
*/
public JsonGardenPlan() {
public JsonCropList() {
this.dataSource = getClass().getResource("user-crops.json");
}
@@ -50,7 +50,7 @@ public class JsonGardenPlan implements GardenPlan {
* Constructor to use a specified {@link URL} as a {@link #dataSource}
* @param dataSource A {@link URL} to the file to be used as a data source
*/
public JsonGardenPlan(URL dataSource) {
public JsonCropList(URL dataSource) {
this.dataSource = dataSource;
}
/**
@@ -20,11 +20,11 @@ import java.util.Map;
import java.util.Optional;
/**
* Implements the {@link PlantDatabase} interface for loading {@link Plant} objects
* Implements the {@link PlantList} interface for loading {@link Plant} objects
* from a JSON file.
* The reads are cached to minimize file-io operations.
*/
public class JsonPlantDatabase implements PlantDatabase {
public class JsonPlantList implements PlantList {
private final URL dataSource = getClass().getResource("plantdb.json");
private HardinessZone currentZone;
@@ -49,7 +49,7 @@ public class JsonPlantDatabase implements PlantDatabase {
* from the {@link #currentZone}, data is loaded from {@link #dataSource}.
* In any case, the values of {@link #plantMap} are returned.
*
* @see PlantDatabase#getPlantList(HardinessZone)
* @see PlantList#getPlantList(HardinessZone)
*/
@Override
public List<Plant> getPlantList(HardinessZone zone) throws IOException, HardinessZoneNotSetException {
@@ -60,7 +60,7 @@ public class JsonPlantDatabase implements PlantDatabase {
}
/**
* @see PlantDatabase#getPlantById(long)
* @see PlantList#getPlantById(long)
*/
@Override
public Optional<Plant> getPlantById(HardinessZone zone, long id) throws HardinessZoneNotSetException, IOException {
@@ -1,6 +1,5 @@
package ch.zhaw.gartenverwaltung.io;
import ch.zhaw.gartenverwaltung.types.Crop;
import ch.zhaw.gartenverwaltung.types.Task;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
@@ -20,11 +19,11 @@ import java.util.List;
import java.util.Map;
/**
* Implements the {@link TaskDatabase} interface for loading and writing {@link Task} objects
* Implements the {@link TaskList} interface for loading and writing {@link Task} objects
* from and to a JSON file.
* The reads are cached to minimize file-io operations.
*/
public class JsonTaskDatabase implements TaskDatabase{
public class JsonTaskList implements TaskList {
IdProvider idProvider;
private final URL dataSource = getClass().getResource("taskdb.json");
private final static String INVALID_DATASOURCE_MSG = "Invalid datasource specified!";
@@ -48,7 +47,7 @@ public class JsonTaskDatabase implements TaskDatabase{
* If no data is currently loaded, data is loaded from {@link #dataSource}.
* In any case, the values of {@link #taskMap} are returned.
*
* @see TaskDatabase#getTaskList(LocalDate, LocalDate)
* @see TaskList#getTaskList(LocalDate, LocalDate)
*/
@Override
public List<Task> getTaskList(LocalDate start, LocalDate end) throws IOException{
@@ -90,7 +89,7 @@ public class JsonTaskDatabase implements TaskDatabase{
* it to the {@link #taskMap}. In any case, the {@link #taskMap} is written
* to the {@link #dataSource}.
*
* @see TaskDatabase#saveTask(Task)
* @see TaskList#saveTask(Task)
*/
@Override
public void saveTask(Task task) throws IOException {
@@ -108,7 +107,7 @@ public class JsonTaskDatabase implements TaskDatabase{
* If the {@link Task}s id is found in the {@link #taskMap}, the Task is removed
* from the {@link #taskMap}. Then the Task are written to the {@link #dataSource}.
*
* @see TaskDatabase#removeTask(Task)
* @see TaskList#removeTask(Task)
*/
@Override
public void removeTask(Task task) throws IOException {
@@ -11,7 +11,7 @@ import java.util.Optional;
* A database of {@link Plant}s.
* The interface specifies the minimal required operations.
*/
public interface PlantDatabase {
public interface PlantList {
/**
* Yields a list of all {@link Plant}s in the database with only data relevant to the specfied {@link HardinessZone}
*
@@ -1,20 +1,16 @@
package ch.zhaw.gartenverwaltung.io;
import ch.zhaw.gartenverwaltung.types.Crop;
import ch.zhaw.gartenverwaltung.types.HardinessZone;
import ch.zhaw.gartenverwaltung.types.Plant;
import ch.zhaw.gartenverwaltung.types.Task;
import java.io.IOException;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
/**
* A database of {@link Task}s.
* The interface specifies the minimal required operations.
*/
public interface TaskDatabase {
public interface TaskList {
/**
* Yields a list of all {@link Task}s in the database with the start and end date of a period of time.
*