-
Notifications
You must be signed in to change notification settings - Fork 5
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
Country filter v1 #121
Country filter v1 #121
Conversation
Codecov Report
@@ Coverage Diff @@
## master #121 +/- ##
============================================
- Coverage 72.10% 71.28% -0.83%
- Complexity 410 440 +30
============================================
Files 76 81 +5
Lines 1269 1379 +110
Branches 127 143 +16
============================================
+ Hits 915 983 +68
- Misses 320 345 +25
- Partials 34 51 +17 Continue to review full report at Codecov.
|
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.
this PR is required for other PRs to be made, hence it got expedited. Should be okay after the minor changes that @tankangliang suggested. Thanks man!
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.
The rest of the code looks good!
src/main/java/seedu/address/logic/commands/CountryNoteCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/seedu/address/logic/parser/CountryFilterCommandParser.java
Outdated
Show resolved
Hide resolved
src/main/java/seedu/address/logic/commands/CountryFilterCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/seedu/address/logic/commands/CountryNoteCommand.java
Outdated
Show resolved
Hide resolved
src/main/java/seedu/address/model/client/CountryMatchesInputCountryPredicate.java
Outdated
Show resolved
Hide resolved
public boolean hasCountryNote(Country country, Note countryNote) { | ||
if (!isValidCode(country.getCountryCode())) { | ||
return false; | ||
} | ||
return countryCodeMap.get(country.getCountryCode()).hasCountryNote(countryNote); | ||
} |
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.
Hmmm I was thinking that this CountryManager class holds all Country objects, while every other class should be holding references to these objects instead of any new Country() object. That way, the class themselves should be able to check if the Country has any notes, and this method would not be needed.
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.
My idea is that whenever you are interacting with the existing Country
instances (other than just getting country notes), you should only do it via CountryManager
. I think this layer of abstraction is good especially for logging/debugging in the future since Model
only needs to operate on CountryManager
and I would be able to log all Country
method calls.
For classes like the CountryNoteParser
or CountryFilterParser
they should not be holding references to the existing Country as they do not have a reference to CountryManager
. Only Model
has a reference to CountryManager
. So when a Command
executes on a Model
, then they are able to check for duplicate notes, etc.
Also, Country
has a hasCountryNote
method, but I purposely made it protected
so that only CountryManager
can call that method. Other classes should only be able to call the constructor and getCountryNote
method of Country
only.
This reverts commit 6c6d2d7
Fixes #108
Basic implementation of
country filter c/COUNTRY_CODE
command. Tested working with GUI oncountry filter c/SG
.@tankangliang note that when u add the country field to Client, you need to update the
client.getCountry()
method as I am hardcoding the return country.Better tests and user feedback messages will be done in a separate issue.