-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[T6A1][W09-B3]Shawn Lin Jingjue #390
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package seedu.addressbook.storage; | ||
|
||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.data.exception.IllegalValueException; | ||
|
||
public interface Storage { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Header comment? And try to follow the class diagram by making this an |
||
|
||
/** Default file path used if the user doesn't provide the file name. */ | ||
String DEFAULT_STORAGE_FILEPATH = "addressbook.txt"; | ||
|
||
/** | ||
* Saves all data to this storage file. | ||
* | ||
* @throws StorageOperationException if there were errors converting and/or storing data to file. | ||
*/ | ||
void save(AddressBook addressBook) throws StorageOperationException; | ||
|
||
/** | ||
* Loads data from this storage file. | ||
* | ||
* @throws StorageOperationException if there were errors reading and/or converting data from file. | ||
*/ | ||
AddressBook load() throws StorageOperationException; | ||
|
||
String getPath(); | ||
|
||
/** | ||
* Signals that the given file path does not fulfill the storage filepath constraints. | ||
*/ | ||
public static class InvalidStorageFilePathException extends IllegalValueException { | ||
public InvalidStorageFilePathException(String message) { | ||
super(message); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
/** | ||
* Signals that some error has occurred while trying to convert and read/write data between the application | ||
* and the storage file. | ||
*/ | ||
public static class StorageOperationException extends Exception { | ||
public StorageOperationException(String message) { | ||
super(message); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package seedu.addressbook.logic; | ||
|
||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.storage.Storage; | ||
|
||
public class StorageStub implements Storage { | ||
|
||
public StorageStub(String path) { | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
@Override | ||
public void save(AddressBook addressBook) throws StorageOperationException { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public AddressBook load() throws StorageOperationException { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getPath() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Good job. Minimal and in the correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 appplying DIP
The creating of
StorageFile
is a little unfortunate, but nonetheless has to be done. The original design already violates OCP. Fyi, an issue has been raised regarding this se-edu/addressbook-level3#75