-
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][W10-B4]Li Chengcheng #527
Changes from all commits
4572d05
1a09752
00149b6
1efd0d2
d92b826
98749de
033f0c9
64c222a
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.data.person.ReadOnlyPerson; | ||
import seedu.addressbook.parser.Parser; | ||
import seedu.addressbook.storage.Storage; | ||
import seedu.addressbook.storage.StorageFile; | ||
|
||
import java.util.Collections; | ||
|
@@ -17,7 +18,7 @@ | |
public class Logic { | ||
|
||
|
||
private StorageFile storage; | ||
private Storage storage; | ||
private AddressBook addressBook; | ||
|
||
/** The list of person shown to the user most recently. */ | ||
|
@@ -28,12 +29,12 @@ public Logic() throws Exception{ | |
setAddressBook(storage.load()); | ||
} | ||
|
||
Logic(StorageFile storageFile, AddressBook addressBook){ | ||
setStorage(storageFile); | ||
Logic(Storage storage, AddressBook addressBook){ | ||
setStorage(storage); | ||
setAddressBook(addressBook); | ||
} | ||
|
||
void setStorage(StorageFile storage){ | ||
void setStorage(Storage storage){ | ||
this.storage = storage; | ||
} | ||
|
||
|
@@ -42,14 +43,14 @@ void setAddressBook(AddressBook addressBook){ | |
} | ||
|
||
/** | ||
* Creates the StorageFile object based on the user specified path (if any) or the default storage path. | ||
* Creates the Storage object based on the user specified path (if any) or the default storage path. | ||
* @throws StorageFile.InvalidStorageFilePathException if the target file path is incorrect. | ||
*/ | ||
private StorageFile initializeStorage() throws StorageFile.InvalidStorageFilePathException { | ||
return new StorageFile(); | ||
private Storage initializeStorage() throws StorageFile.InvalidStorageFilePathException { | ||
return new StorageFile();//I'm not sure how to get rid of this coupling | ||
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. Yes, this part is unfortunate, but it's the best we can do right now. The original design already violates OCP. Fyi, an issue has been raised regarding this se-edu/addressbook-level3#75 |
||
} | ||
|
||
public String getStorageFilePath() { | ||
public String getStoragePath() { | ||
return storage.getPath(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package seedu.addressbook.storage; | ||
|
||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.storage.StorageFile.StorageOperationException; | ||
|
||
/** | ||
* Represents the file used to store address book data. | ||
*/ | ||
public abstract class Storage { | ||
public abstract AddressBook load() throws StorageOperationException; | ||
public abstract void save(AddressBook addressBook) throws StorageOperationException; | ||
public abstract String getPath(); | ||
} | ||
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. 👍 but careful with identation... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package seedu.addressbook.storage; | ||
|
||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.storage.StorageFile.StorageOperationException; | ||
|
||
public class StorageStub extends 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 will be useful... |
||
|
||
private String path; | ||
|
||
public StorageStub(String path) { | ||
this.path = path; | ||
} | ||
|
||
@Override | ||
public void save(AddressBook addressBook) throws StorageOperationException { | ||
return; | ||
} | ||
|
||
@Override | ||
public AddressBook load() throws StorageOperationException { | ||
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. 👍 |
||
} | ||
|
||
@Override | ||
public String getPath() { | ||
return path; | ||
} | ||
|
||
} | ||
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. 👍 better to put |
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.
👍