package ch.zhaw.gartenverwaltung.io;

import ch.zhaw.gartenverwaltung.types.Crop;

import java.io.IOException;
import java.util.List;
import java.util.Optional;

public interface GardenPlan {
    /**
     * Yields a list of all {@link Crop}s in the database.
     *
     * @return A list of all {@link Crop}s in the database
     * @throws IOException If there is a problem reading from or writing to the database
     */
    List<Crop> getCrops() throws IOException;

    /**
     * Attempts to retrieve the {@link Crop} with the specified cropId.
     *
     * @param cropId The {@link Crop} to look for
     * @return {@link Optional} of the found {@link Crop}, {@link Optional#empty()} if no entry matched the criteria
     * @throws IOException If there is a problem reading from or writing to the database
     */
    Optional<Crop> getCropById(long cropId) throws IOException;

    /**
     * Saves a Crop to the Database.
     *
     * @param crop The {@link Crop} to be saved
     * @throws IOException If there is a problem reading from or writing to the database
     */
    void saveCrop(Crop crop) throws IOException;

    /**
     * Removes a Crop from the Database.
     *
     * @param crop The {@link Crop} to be removed
     * @throws IOException If there is a problem reading from or writing to the database
     */
    void removeCrop(Crop crop) throws IOException;
}
