package ch.zhaw.gartenverwaltung.io;

import ch.zhaw.gartenverwaltung.types.Plant;
import ch.zhaw.gartenverwaltung.types.HardinessZone;

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

/**
 * A database of {@link Plant}s.
 * The interface specifies the minimal required operations.
 */
public interface PlantDatabase {
    /**
     * Yields a list of all {@link Plant}s in the database with only data relevant to the specfied {@link HardinessZone}
     *
     * @param zone The zone for which data should be fetched
     * @return A list of {@link Plant}s with data for the specified zone
     * @throws IOException If the database cannot be accessed
     * @throws HardinessZoneNotSetException If no {@link HardinessZone} was specified
     */
    List<Plant> getPlantList(HardinessZone zone) throws IOException, HardinessZoneNotSetException;

    /**
     * Attempts to retrieve the {@link Plant} with the specified id.
     *
     * @param id The {@link Plant#id()} to look for
     * @return {@link Optional} of the found {@link Plant}, {@link Optional#empty()} if no entry matched the criteria
     * @throws IOException If the database cannot be accessed
     * @throws HardinessZoneNotSetException If no {@link HardinessZone} was specified
     */
    Optional<Plant> getPlantById(HardinessZone zone, long id) throws IOException, HardinessZoneNotSetException;
}
