forked from nus-cs2103-AY1819S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 5
/
AddressBookStorage.java
45 lines (36 loc) · 1.44 KB
/
AddressBookStorage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package seedu.address.storage;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Optional;
import seedu.address.commons.exceptions.DataConversionException;
import seedu.address.model.ReadOnlyAddressBook;
/**
* Represents a storage for {@link seedu.address.model.AddressBook}.
*/
public interface AddressBookStorage {
/**
* Returns the file path of the data file.
*/
Path getAddressBookFilePath();
/**
* Returns AddressBook data as a {@link ReadOnlyAddressBook}.
* Returns {@code Optional.empty()} if storage file is not found.
* @throws DataConversionException if the data in storage is not in the expected format.
* @throws IOException if there was any problem when reading from the storage.
*/
Optional<ReadOnlyAddressBook> readAddressBook() throws DataConversionException, IOException;
/**
* @see #getAddressBookFilePath()
*/
Optional<ReadOnlyAddressBook> readAddressBook(Path filePath) throws DataConversionException, IOException;
/**
* Saves the given {@link ReadOnlyAddressBook} to the storage.
* @param addressBook cannot be null.
* @throws IOException if there was any problem writing to the file.
*/
void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException;
/**
* @see #saveAddressBook(ReadOnlyAddressBook)
*/
void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) throws IOException;
}